AnsweredAssumed Answered

Adding points to graphicsLayer using feature's coordinates stored in attributes

Question asked by monzay on Apr 30, 2013
Latest reply on May 1, 2013 by monzay
Is it possible to add graphic points to the map or graphicsLayer using coordinates stored in the feature? I'm using a query to collect the features I'm interested in. The function addToMap will display those polygons on a the map graphics layer or another graphics Layer (I did that just to test it). I want to add a point marker on top using the coordinates in the feature. The coordinate fields type are double. I haven't been able to retrieve those coordinates even to show them through console.log much less create a graphic point. Various attempts show undefined.

function addToMap(featureSet) {      //initialize symbology         defaultSymbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([255,0,255]));            var iconSymbol = new esri.symbol.PictureMarkerSymbol({           "angle":0,           "xoffset":0,           "yoffset":10,           "type":"esriPMS",           "url":"",           "contentType":"image/png",           "width":24,           "height":24         });      var gLayer = new esri.layers.GraphicsLayer();         iTemplate = new esri.InfoTemplate("Sitename", "<tr><td>${Sitename}</tr></td>");         map.addLayer(gLayer);          dojo.forEach(featureSet.features,function(feature){ ;           //gLayer.add(feature.setSymbol(defaultSymbol).setInfoTemplate(iTemplate));           //var ptX = feature.attributes.centroidLongitude; // returns undefined           //var ptX = feature.centroidLongitude; // returns undefined           //var ptY = feature.attributes.centroidLatitude;    console.log(ptX);           gLayer.add(new esri.geometry.Point(ptX,ptY,map.spatialReference).setSymbol(iconSymbol));                      });