Disable Leaflet Interaction – How to Temporarily Disable Leaflet Interaction

leaflet

How can I temporary disable zoming/draging the Mapview in Leaflet.js
Tried so many ways but without any luck.
It's important to make it temporary and I also need the option to enable again.

Best Answer

your going to want to do (assuming your map is call map)

map.dragging.disable();
map.touchZoom.disable();
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
map.boxZoom.disable();
map.keyboard.disable();
if (map.tap) map.tap.disable();
document.getElementById('map').style.cursor='default';

turn it on again with

map.dragging.enable();
map.touchZoom.enable();
map.doubleClickZoom.enable();
map.scrollWheelZoom.enable();
map.boxZoom.enable();
map.keyboard.enable();
if (map.tap) map.tap.enable();
document.getElementById('map').style.cursor='grab';