7

I have a leaflet marker created similar to the example below.

var marker = L.marker([map.getCenter().lat,map.getCenter().lng], {      
      alt: tempID,
      icon: starIcon,
      draggable: true
  })    
  .addTo(map)  

I would like to toggle the draggable property. I've tried accessing manually like below to no avail.. Any suggestions?

marker.options.draggable=false;

1 Answer 1

12

try

marker.dragging.disable();

and to re-enable:

marker.dragging.enable();

reference:
http://leafletjs.com/reference.html#marker-dragging

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .