[OpenLayers-Users] get lonlat from current zoom map.getExtent()

Christoph Böhme christoph at b3e.net
Fri Apr 3 07:05:56 EDT 2009


"Luis Ortiz (lortiz)" <lortiz at compegps.com> schrieb:
> map = new OpenLayers.Map("map", options);
> 
> map.getExtent().toBBOX()
> 
> and i get coordinates in meters, but i would like to get in Lat/Lon

You need to transform the extent back from EPSG900913 to EPSG4346:

var EPSG4326 = new OpenLayers.Projection("EPSG:4326");
var EPSG900913 = new OpenLayers.Projection("EPSG:900913");
var bounds = map.getExtent().clone();
bounds = bounds.transform(EPSG900913, EPSG4326);
bbox = bounds.toBBOX();

I found reading the wiki page on Spherical Mercator really helpful:
http://docs.openlayers.org/library/spherical_mercator.html

Cheers,
Christoph



More information about the Users mailing list