Search code examples
javascriptleaflet

It is possible to dynamically change "dragging map option"?


It is possible to dynamically change "dragging map option"?

I set "dragging: false", but i need to be able to change this option when i click a button.

How can i do that?

Thanks and sorry form my English.

I have tried with invalidateSize() but it doesn't work...


Solution

  • Leaflet includes a class, L.Draggable to make objects draggable. This utility class is added to both markers and the map itself. Both have a property named dragging with enable and disable methods:

    marker.dragging.disable();
    

    The configuration property dragging when you create a map instance sets the default state.