[GIS] display openlayers lat/long map bound on page

openlayers-2

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.

Best Answer

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!