I have a leaflet map, containing a tileLayer, and a layerGroup
In the layerGroup, I plot circleMarkers, and then connect them with a polyline.
Though the markers are defined as draggable, I get no drag events for them, and any attempt to drag them results in moving the whole map. I thought it must be because the polyline is on top of the markers, but no such luck. polyline.bringToBack()
didn't help.
var multiLine = [];
var line = [];
towTrack.clearLayers();
for (var ix = 0; ix < display_rows.length; ix++) {
var row = display_rows[ix];
var lon = row.EventLongitude;
var lat = row.EventLatitude;
if (lat != null && lon != null) {
var pos = [lat, lon];
line.push(pos);
var marker = L.circleMarker(pos, {
radius: 5,
color: 'yellow',
weight: 1,
draggable: true
}).addTo(towTrack);
marker
.on('dragend', function (e) {
var position = e.target.getLatLng();
e.target.setLatLng(new L.LatLng(position.lat, position.lng), { draggable: 'true' });
});
if (row.EventCode == 4 || row.EventCode == 9) {
multiLine.push(line);
}
}
}
var polyline = L.polyline(multiLine, { color: 'red', weight: 1 }).addTo(towTrack);
polyline.bringToBack();
L.CircleMarker
is anL.Path
, not anL.Marker
. I think maybe I'll just useL.Marker
with an icon.