I would like to be able to drag a marker out of the map area onto some other (drop-enabled) element on the page (to include it in a list for example). How can I do this with leaflet? If I try to drag a marker out of the map, it just disappears underneath the area surrounding the map...
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You won't be able to do this with leaflet functionality. One approach could be:
- Listen for event on marker. You don't actually want the markers draggable in terms of changing locations so you probably want to change that setting within the marker and use the mouse down event or something.
- Create element to drag and drop outside of map but set its z-index and other css properties to so it appears to be a marker.
- Use drag and drop from html5/jquery/etc to place in container.
FYI: Here is the opposite approach of having a draggable object moved on to the map and then inserted as a marker.