user3398945
user3398945

Reputation: 93

Marker setDraggable for Leaflet?

With Leaflet, any suggestions on how to change the draggability of a marker from another event?

For example, I have:

marker = (L.marker([0,0], {draggable: true}));

Then later I can do such things as:

marker.setIcon(myicon).setLatLng(mylatlng).addTo(map);

How would I also change draggable to false? I have multiple markers and I need to toggle the draggability for individual markers, so I also don't want to freeze the whole map.

Thanks

Upvotes: 1

Views: 1420

Answers (1)

YaFred
YaFred

Reputation: 10018

The answer is in the documentation: http://leafletjs.com/reference.html#marker

marker.dragging.enable();

marker.dragging.disable();

Upvotes: 3

Related Questions