If a marker gets snapped to another marker before it was unsnapped from from the previous marker, no unsnap event is fired. Here is a working proposal to fix the issue by first firing the unsnap event before doing a new snap:
L.Snap.updateSnap = function (marker, layer, latlng) {
if (! marker.hasOwnProperty('_latlng')) {
return;
}
if(marker.snap != layer){
if (marker.snap) {
if (marker._icon) {
L.DomUtil.removeClass(marker._icon, 'marker-snapped');
}
marker.fire('unsnap', {layer: marker.snap});
}
delete marker.snap;
}
if (layer && latlng) {
// don't call setLatLng so that we don't fire an unnecessary 'move' event
marker._latlng = L.latLng(latlng);
marker.update();
if (marker.snap != layer) {
marker.snap = layer;
if (marker._icon) {
L.DomUtil.addClass(marker._icon, 'marker-snapped');
}
marker.fire('snap', {layer:layer, latlng: latlng});
}
}
};
If a marker gets snapped to another marker before it was unsnapped from from the previous marker, no unsnap event is fired. Here is a working proposal to fix the issue by first firing the unsnap event before doing a new snap: