question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

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:closed
  • Created 7 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
lecrapalcommented, Nov 2, 2016

Same problem here 😕

0reactions
ghybscommented, Apr 15, 2017

Hi,

Works with Leaflet 1.0.3 + Leaflet.markercluster 1.0.4: https://jsfiddle.net/3v7hd2vx/245/

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found