Loading PictureMarkerSymbol

625
2
10-17-2010 04:01 AM
zeeshanbhatti
New Contributor
I am new to ArcGIS API for Javascript. I am trying to add graphics. which includes Image,line,polygon. I am trying the reference link

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm

I am stuck while trying to load line using desired positions longitude and latitude. Kindly if some one can help me out with some code modification that what i m missing here ?. i m putting my code in which i m loading Line..Later In the case of succeed i will load rest of graphics.Thanks


<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
    <script type="text/javascript">
        dojo.require("esri.map");
        dojo.require("esri.graphic");

            function init() {
            var initExtent = new esri.geometry.Extent({ "xmin": 5129249.759455201, "ymin": 3361184.138260187, "xmax": 5520607.344275116, "ymax": 3463304.0080491337, "spatialReference": { "wkid": 102100} });
            var map = new esri.Map("map", { extent: initExtent });
            dojo.connect(map, "onload", Draw_Symbol());
         
            var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
            map.addLayer(tiledMapServiceLayer);         

        }
  function Draw_Symbol() {
            var pt = new esri.geometry.Point(47.249625077193045, 29.526414016317314, map.spatialReference)
            var sms = new esri.symbol.SimpleMarkerSymbol().setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE).setColor(new dojo.Color([255,0,0,0.5]));
            var attr = {"XCoord":evt.mapPoint.x,"YCoord":evt.mapPoint.y,"Plant":"Mesa Mint"};
            var infoTemplate = new esri.InfoTemplate("Vernal Pool Locations","Latitude: ${YCoord},Longitude: ${XCoord} Plant Name:${Plant}");
            var graphic = new esri.Graphic(pt,sms,attr,infoTemplate);            
              //tried map.graphics.add(graphics); but error
             }

        dojo.addOnLoad(init);
</script>


Regards,
Zeeshan
0 Kudos
2 Replies
zeeshanbhatti
New Contributor
I would like to brief more about my previous statment is that i need to load different markers on the map along with different longitude & latitude.
0 Kudos
rajeshmanam
New Contributor
Hi,

I think it is not getting the map.spatialreference value.
problem with this statement (var pt = new esri.geometry.Point(47.249625077193045, 29.526414016317314, map.spatialReference))

you need to make the map variable declaration in global area, probably outside of init().

hope this will help.

- Rajesh
0 Kudos