I have a back to home function
function panToHome(){
latLng = [current.lat, current.lng];
map.setView(latLng, 8);
}
I want to save the current view as history, so user can switch back as they might click mistakely. So the question is how can I know the current latlng on Mapbox?!
Use the getZoom method on your L.mapbox.map instance:
Returns the current zoom of the map view.
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();
Here zoom holds 9
In Android you can use
int currentZoomLevel = mapboxMap.getCameraPosition().zoom;
On iOS with Mapbox SDK 4.0, there's a .zoomLevel property on the MGLMapView object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With