Search code examples
javascriptionic-frameworkopenlayers-3angular-openlayers

how to get the current zoom in openlayers


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


Solution

  • 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();