[GIS] How to get the latitude & longitude of the 4 corners of the map being displayed

latitude longitudeopenlayers

I am working on OpenLayers (ol3) and I want to get the Latitude, Longitude of the corners of the map being shown at a point. I tried using map.getView().getProjection().getExtent() and converting the points from 'EPSG:3857' to 'EPSG:4326' but I get -180,-85.05112877980659,180,85.05112877980659 irrespective of the zoom level of the map I have set.

I would like to know the map view corner points dynamically.

Best Answer

You can get the current extent with:

var extent = map.getView().calculateExtent(map.getSize());

Then you can use ol.proj.transformExtent to reproject the extent.

Related Question