Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get the bounding box of the map area displayed by OpenLayers.

I tried to use map.getExtent() because it should be exactly what I need, but the returned values are "strange":

For example, if I center the map around Grenoble (France, 45.19 5.71) with zoom level 14, the getExtent returns : 634409.225396,5647894.800465,643008.391077,5652672.114732 I guess I'm doing something wrong, but I can't figure out what. The getExtent() is supposed to return a bound object with Lat/Lon values...

The map is created with :

var map = new OpenLayers.Map('map', {
  projection: new OpenLayers.Projection("EPSG:900913"),
  displayProjection: new OpenLayers.Projection("EPSG:4326")

I'm using OSM as my base layer.

share|improve this question
up vote 11 down vote accepted

Looks like the coordinates are coming back in the map's projection (epsg 900913 AKA web mercator). You should be able to call transform on your bounds object to convert it to lat/long. Try something like this (untested):

map.getExtent().transform(map.projection, map.displayProjection)
share|improve this answer
+1 - the displayProjection is only used by some controls that display coordinates – geographika May 22 '11 at 21:14
Works perfectly ! I've spent nearly 1h30 on this without sucess (at least I've read a good part of OL docs) Thanks a lot ! – Marc May 23 '11 at 6:57
You're welcome! – Derek Swingley May 23 '11 at 14:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.