diff --git a/debug/tests/remove_while_dragging.html b/debug/tests/remove_while_dragging.html new file mode 100644 index 00000000..6da80b53 --- /dev/null +++ b/debug/tests/remove_while_dragging.html @@ -0,0 +1,29 @@ + + + + Leaflet debug page + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/src/layer/marker/Marker.Drag.js b/src/layer/marker/Marker.Drag.js index 93786d41..822f5dac 100644 --- a/src/layer/marker/Marker.Drag.js +++ b/src/layer/marker/Marker.Drag.js @@ -19,6 +19,11 @@ L.Handler.MarkerDrag = L.Handler.extend({ }, removeHooks: function () { + this._draggable + .off('dragstart', this._onDragStart) + .off('drag', this._onDrag) + .off('dragend', this._onDragEnd); + this._draggable.disable(); }, diff --git a/src/layer/marker/Marker.js b/src/layer/marker/Marker.js index 2c3a76a8..5c0687f0 100644 --- a/src/layer/marker/Marker.js +++ b/src/layer/marker/Marker.js @@ -41,6 +41,10 @@ L.Marker = L.Class.extend({ }, onRemove: function (map) { + if (this.dragging) { + this.dragging.disable(); + } + this._removeIcon(); this.fire('remove');