lat,lng to webmercator

643
3
12-22-2010 01:08 PM
timgogl
New Contributor II
ok, well i have been searching for info on this for a chunk of the day today, and finally found this thread that looked like it was what i needed....

so i new have this function:
  function findLocation(){
   
   console.log('find location');
   var lat = latToFind;  //44.071
   var lng = lngToFind; //-122.199
   
   console.log('make new point');
   var pt = new esri.geometry.Point(lng,lat,new esri.SpatialReference({'wkid':2994}));
   console.log(pt);
   console.log('make new webmercator point');
   var xyPt = new esri.geometry.geographicToWebMercator(pt);
   console.log(xyPt);
   var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 14,
           new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color(MARK_OUTLINE_COLOR), 2), new dojo.Color(MARK_FILL_COLOR));
   var graphic = new esri.Graphic(xyPt,symbol);
   
   console.log('add graphic');
   map.graphics.add(graphic);
   
  }



so, this code all seams to run ok... the console logs all my messages with no errors.
however....

my graphic is not being added to the map (or at least not on the visible map).

when i examine the xyPt information inside the console, i noticed that the wkid is 102100.

so, my question is, what am i doing wrong, how can i get this functionality but have the wkid remain 2994?

thanks for any help you can offer.
0 Kudos
3 Replies
timgogl
New Contributor II
ok. i got this one figured out... i need to use the project method from the geometry service....

thanks for taking a look.
0 Kudos
PaulForbess
New Contributor III
there are also these methods:

esri.geometry.webMercatorToGeographic(geometry)
esri.geometry.geographicToWebMercator(geometry)
0 Kudos
BrandonCales
New Contributor III
Mind sharing your code?

ok, well i have been searching for info on this for a chunk of the day today, and finally found this thread that looked like it was what i needed....

so i new have this function:
  function findLocation(){
   
   console.log('find location');
   var lat = latToFind;  //44.071
   var lng = lngToFind; //-122.199
   
   console.log('make new point');
   var pt = new esri.geometry.Point(lng,lat,new esri.SpatialReference({'wkid':2994}));
   console.log(pt);
   console.log('make new webmercator point');
   var xyPt = new esri.geometry.geographicToWebMercator(pt);
   console.log(xyPt);
   var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 14,
           new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color(MARK_OUTLINE_COLOR), 2), new dojo.Color(MARK_FILL_COLOR));
   var graphic = new esri.Graphic(xyPt,symbol);
   
   console.log('add graphic');
   map.graphics.add(graphic);
   
  }



so, this code all seams to run ok... the console logs all my messages with no errors.
however....

my graphic is not being added to the map (or at least not on the visible map).

when i examine the xyPt information inside the console, i noticed that the wkid is 102100.

so, my question is, what am i doing wrong, how can i get this functionality but have the wkid remain 2994?

thanks for any help you can offer.
0 Kudos