I'm using a Leaflet map with markers.
When the user clicks "edit" on my page, I want to make the markers draggable. If I set the property draggable
to true for each marker, it doesn't work.
When I create a new marker and set the property right from the beginning, it works.
You gotta do it like this:
marker.dragging.disable(); // marker.dragging.enable();
My first attempt only changes a technical property but not the behavior.
Motivated by @mc0e problem concerning 'undefined'. Here is an example.
(Based on the code from Leafletjs.com and Leafletjs quick start)
Code-1 in console:
var markerLondon = L.marker()
.setLatLng([51.5, -0.09])
.bindPopup('Centre of London')
.addTo(map)
.openPopup();
Code-2 in console:
markerLondon.dragging.enable();
Further reading: Marker API reference.
PS: Once Wikimedia starts using something else, you may test it with BigMap 2 (also based on the same framework) created for making static OpenStreetMap images.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With