Dragging markers
See original GitHub issueHi,
I’m having trouble dragging markers on map. I have read old issues regarding this topic and if I have understood correctly, one needs to first remove marker from cluster on dragstart-event and add it back to cluster on dragend-event. Also this marker needs to be added to the map after removing it from cluster so that it doesn’t disappear when moving it.
var markers = L.markerClusterGroup({ disableClusteringAtZoom: 12 });
var marker = L.marker([pos.lat, pos.lng], { title: "title", draggable: "true" });
marker.on("dragstart", function (ev) {
console.log("drag start");
markers.removeLayer(this);
marker.addTo(mMapView);
});
marker.on("drag", function (ev) {
console.log("drag");
this.setLatLng(ev.latlng);
});
marker.on("dragend", function (ev) {
console.log("drag end");
marker.removeFrom(mMapView);
markers.addLayer(this);
});
markers.addLayer(marker);
This almost works. When I try to drag the marker, it doesn’t move at all (dragstart-event fires but not others). After the mouse button is released and I try dragging again, it works.
Any ideas on how I could get this to work?
I’m using: Leaflet v1.0.0-rc.1 Leaflet-markercluster v1.0.0-rc.1 Latest Chrome on Windows 8.1
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Drag and drop markers question type - MoodleDocs
This question type allows students to drop markers onto an area on a background image. Drag and drop markers questions differ from Drag...
Read more >Drag & Drop Markers | Reverse Geocoding - YouTube
Drag & Drop Markers | Reverse Geocoding ; In this video you will learn how to add # marker ; on map using...
Read more >Drag and Drop Markers - AWS
The Drag and Drop Markers question type requires students to drag and drop words onto defined regions of an image. This document illustrates...
Read more >Drag & Drop Marker Questions in Moodle - UMass Amherst
Drag & Drop Marker Questions in Moodle. Drag and drop markers questions require students to drag and drop a marker onto a background...
Read more >Adding, selecting, and dragging markers in maps
It is possible to add markers onto the map via a data model and then select or drag it by interacting with the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same problem here 😕
Hi,
Works with Leaflet 1.0.3 + Leaflet.markercluster 1.0.4: https://jsfiddle.net/3v7hd2vx/245/