how to get the current zoom in openlayers

Ivan Paredes picture Ivan Paredes · Aug 18, 2016 · Viewed 11.8k times · Source

i have a question. i need to know the actual zoom of the open layers map

$scope.refreshMap = function (lat, long) {
    map.setView(new ol.View({
        projection: 'EPSG:4326',
        center: [long, lat], 
        zoom: "here I do not know what to put"
    }));
};

i try with map.getZoom() but it doesn't work. the logcat throws me a

Uncaught TypeError: Object #<S> has no method 'getZoom'

i'm using the openlayers Version: v3.16.0

Answer

Jonatas Walker picture Jonatas Walker · Aug 18, 2016

Zoom is a property of ol.View. So ol.Map has a ol.View that has zoom level, center, projection to say some.

map.getView().getZoom();