diff --git a/debug/map/remove_while_dragging.html b/debug/map/remove_while_dragging.html new file mode 100644 index 00000000..6da80b53 --- /dev/null +++ b/debug/map/remove_while_dragging.html @@ -0,0 +1,29 @@ + + + + Leaflet debug page + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js index 4c8c53d3..ac0cea50 100644 --- a/src/dom/Draggable.js +++ b/src/dom/Draggable.js @@ -37,6 +37,10 @@ L.Draggable = L.Class.extend({ disable: function () { if (!this._enabled) { return; } + + this.off('dragstart', this._onDragStart) + .off('drag', this._onDrag) + .off('dragend', this._onDragEnd); for (var i = L.Draggable.START.length - 1; i >= 0; i--) { L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this); diff --git a/src/layer/marker/Marker.js b/src/layer/marker/Marker.js index 2c3a76a8..64bb44cd 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.removeHooks(); + } + this._removeIcon(); this.fire('remove');