I\'m trying to remove the zoom controls (+/-) on a LeafletJS map.
I\'m using the MapBox.js version of Leaflet but most of the operations are the same as Leaflet. I
you can remove the control zoomControl
in this way:
map.removeControl(map.zoomControl);
If you want to dynamically turn on and off zooming you can do something like this:
map.touchZoom.disable();
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
map.boxZoom.disable();
map.keyboard.disable();
$(".leaflet-control-zoom").css("visibility", "hidden");
map.scrollWheelZoom.disable();
To dynamically remove then add back the zoom control:
var map = L.mapbox.map('map');
if( wantToRemove ) {
map.removeControl( map.zoomControl );
} else {
map.addControl( map.zoomControl );
}
This worked for me:
var map = new L.map('map', { zoomControl: false });
With mapbox try:
var map = L.mapbox.map('map', { zoomControl: false });
See map creation and the zoomControl option in the Leaflet documentation.
You can just use
map.zoomControl.remove();