0
我想圍繞標記畫一個正方形。如果我畫一個大方塊,地圖應該自動縮小,以便我們可以完全看到方塊。如果我畫一個小方塊,地圖應該自動放大以完全顯示方塊。如何以編程方式縮放地圖Openlayers 3?
In this image i have drawn small square so we can see the square completely
我想圍繞標記畫一個正方形。如果我畫一個大方塊,地圖應該自動縮小,以便我們可以完全看到方塊。如果我畫一個小方塊,地圖應該自動放大以完全顯示方塊。如何以編程方式縮放地圖Openlayers 3?
In this image i have drawn small square so we can see the square completely
看到的OpenLayers ol.View 3文檔。有一個功能setZoom(zoom)
。
所以,如果你的地圖變量是map
,在使用map.getView().setZoom(map.getView().getZoom() + 1);
放大和縮小使用map.getView().setZoom(map.getView().getZoom() + 1);