You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What happens is that the marker is removed all right, but I'm getting an Uncaught TypeError: Cannot read property 'dragging' of null error that comes from the end of the _onDragEnd function here:
It looks like removing the marker from the map invalidates the map reference stored in this._path._map? The workaround I've come up with is to store a direct reference to the map, like this:
--- a/include/leaflet-path-drag-1.1.0/L.Path.Drag-src.js+++ b/include/leaflet-path-drag-1.1.0/L.Path.Drag-src.js@@ -160,6 +160,8 @@ L.Handler.PathDrag = L.Handler.extend( /** @lends L.Path.Drag.prototype */ {
.on(document, MOVE[eventType], this._onDrag, this)
.on(document, END[eventType], this._onDragEnd, this);
+ this._map = this._path._map;+
if (this._path._map.dragging.enabled()) {
// I guess it's required because mousdown gets simulated with a delay
//this._path._map.dragging._draggable._onUp(evt);
@@ -267,7 +269,7 @@ L.Handler.PathDrag = L.Handler.extend( /** @lends L.Path.Drag.prototype */ {
if (this._mapDraggingWasEnabled) {
if (moved) L.DomEvent.fakeStop({ type: 'click' });
- this._path._map.dragging.enable();+ this._map.dragging.enable();
}
},
It works but maybe there is a better way? Also let me know if you'd be interested in having a PR for this.
The text was updated successfully, but these errors were encountered:
Hi, and first of all thanks for making this plug-in available!
I'm using Leaflet.Path.Drag v1.1.0 with leaflet 1.4 and I want to remove a marker on
dragend
. Here is a minimal example of what I'm trying to do:What happens is that the marker is removed all right, but I'm getting an
Uncaught TypeError: Cannot read property 'dragging' of null
error that comes from the end of the_onDragEnd
function here:Leaflet.Path.Drag/dist/L.Path.Drag-src.js
Line 270 in df9c39b
It looks like removing the marker from the map invalidates the map reference stored in
this._path._map
? The workaround I've come up with is to store a direct reference to the map, like this:It works but maybe there is a better way? Also let me know if you'd be interested in having a PR for this.
The text was updated successfully, but these errors were encountered: