[英]how to get the current zoom in openlayers
我有個問題。 我需要知道開放圖層地圖的實際縮放
$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"
}));
};
我嘗試使用map.getZoom()
但它不起作用。 logcat會讓我失望
Uncaught TypeError: Object #<S> has no method 'getZoom'
我正在使用openlayers版本:v3.16.0
縮放是ol.View
的屬性。 所以ol.Map
有一個ol.View
,它有縮放級別,中心,投影ol.View
。
map.getView().getZoom();
$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
}));
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.