Does anyone know how to suppress panning when you click and drag over top of a div box embedded within the map itself?
For example here, when you click and drag over top of the legend, the map drags with you. I want to suppress that function.
I am aware if this technique, but i want to know if this is the only way:
map.dragging.disable();
Best Answer
Using the example from the Leaflet website, note where the
L.Control
object is instantiated asinfo
; this is the<div>
box in the upper-right associated with the map's hover interaction. Here is where it is defined inindex.html
from the Leaflet example:To disable the dragging when a user's cursor is inside this
<div>
box, add an event listener to theHTMLElement
(a<div>
element) that contains theL.Control
object:Recall that
map
was defined as theL.Map
instance earlier.