Reputation: 575
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
Upvotes: 25
Views: 20622
Reputation: 575
$scope.refreshMap = function (lat, long) {
var actualZoom = map.getView().getZoom();
console.log(z);
map.setView(new ol.View({
projection: 'EPSG:4326',
center: [long, lat], //long,lat
zoom: actualZoom
}));
};
Upvotes: 0
Reputation: 14168
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();
Upvotes: 46