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 want to display the bounds of my current extent on the page. I am not too great with javascript. I know it must be related to this: map.getLonLatFromPixel(new OpenLayers.Pixel(bounds.left, bounds.bottom))

Can't seem to get it. Any help would be great! Thanks.

share|improve this question

I think you are looking for map.getExtent():

This will give you a bounds object in the coordinate-system of your map. The Bounds object ( has several methods for getting the bound-coordinates, the simplest beeing toString.

Hope this helps!

share|improve this answer
You will likely want to transform those bounds to the epsg:4326 projection to get the "normal" lat/lon coordinates we're all used to. Especially if you're just starting out I'm assuming you're using a mercator (google/bing/OSM) base map. Just FYI. These are all assumptions. – Vadim Apr 12 '12 at 16:45
Good point, forgot to mention that. I am so used to working with WMSes in various UTM zones that I forgot this. – atlefren Apr 12 '12 at 18:28

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.