Select to view content in your preferred language

trying to display my point

694
2
04-21-2011 04:23 AM
KirillLykov
Emerging Contributor
I'm trying to display my point using the following code:

var extent = new esri.geometry.Extent(
 { "xmin":-97.0,"ymin":38.0,"xmax":-96.0,
           "ymax":39.0,"spatialReference":{"wkid":4269}});
map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(extent)});

//... then in the call back function for map's onLoad event:
 
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(8);
symbol.setColor(new dojo.Color([255,255,0,0.5]));
  
var point = new esri.geometry.Point(x, y);
var graphic = new esri.Graphic(point, symbol);
map.graphics.add(graphic);


The problem is this code always displays point somewhere in in the Africa and it doesn't depend on the x, y values passed to the Point constructor. For instance, I tried 0.0,0.0 and -80.12468662, 40.42756484.
Where is the mistake? Perhaps, I need to convert point to be point in the display coordinates? How can I do this?
0 Kudos
2 Replies
MarkHoover
Frequent Contributor
Try putting this line:

point = esri.geometry.geographicToWebMercator(point);

right after you create your point.
0 Kudos
KirillLykov
Emerging Contributor
It helped. thanks
0 Kudos