Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer 1

I think you are looking for map.getExtent(): http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Map-js.html#OpenLayers.Map.getExtent

This will give you a bounds object in the coordinate-system of your map. The Bounds object (http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/BaseTypes/Bounds-js.html) 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
add comment

Your Answer

 
discard

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.