[OpenLayers-Users] How to get mouse position to Lat / Lon for SPERICAL Mercator

brancusi roger.moffatt at gmail.com
Fri Feb 6 14:12:16 EST 2009



Christopher Schmidt-2 wrote:
> 
> http://docs.openlayers.org/library/spherical_mercator#reprojecting-points-bounds
> 

Thanks Christopher, I read that and was confused a bit by it. I hope
Jennifer won't mind me posting the code fragment she kindly emailed directly
to me - it solved the question directly and perhaps it might help others who
are searching for the same answer;

map.events.register("mousemove", map, function(e) {
  var pixel = new OpenLayers.Pixel(e.xy.x,e.xy.y);
  var lonlat = map.getLonLatFromPixel(pixel);
  var lonlatGCS =
OpenLayers.Layer.SphericalMercator.inverseMercator(lonlat.lon, lonlat.lat);

 ...



-- 
View this message in context: http://n2.nabble.com/How-to-get-mouse-position-to-Lat---Lon-for-SPERICAL-Mercator-tp2285117p2285965.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list