如何读取地图框的当前缩放级别



我有一个回到主页函数

function panToHome(){
    latLng = [current.lat, current.lng];
    map.setView(latLng, 8);
}

我想将当前视图另存为历史记录,以便用户可以切换回来,因为他们可能会错误地单击。所以问题是我怎么知道 Mapbox 上的当前 latlng?!

L.mapbox.map实例上使用 getZoom 方法:

返回地图视图的当前缩放比例。

http://leafletjs.com/reference.html#map-getzoom

var mapbox = new L.mapbox.map('mapbox', 'mapbox.streets', {
    'center': [0, 0],
    'zoom': 9
});
var zoom = mapbox.getZoom();

在这里,zoom 9

在安卓中你可以使用

int currentZoomLevel = mapboxMap.getCameraPosition().zoom;

在装有 Mapbox SDK 4.0 的 iOS 上,MGLMapView 对象上有一个 .zoomLevel 属性。

最新更新