Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the current zoom in openlayers

Tags:

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

like image 591
Ivan Paredes Avatar asked Aug 18 '16 12:08

Ivan Paredes


1 Answers

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();
like image 52
Jonatas Walker Avatar answered Sep 21 '22 07:09

Jonatas Walker