From 734ea2fdbf67cc7e251e10d82f2566cf97cc7099 Mon Sep 17 00:00:00 2001 From: danzel Date: Fri, 28 Sep 2012 10:46:57 +1200 Subject: [PATCH] Fix deleting 2 end nodes from a poly line. Fixes #1022 --- src/layer/vector/Polyline.Edit.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/layer/vector/Polyline.Edit.js b/src/layer/vector/Polyline.Edit.js index ba2738ae..5a89f4f8 100644 --- a/src/layer/vector/Polyline.Edit.js +++ b/src/layer/vector/Polyline.Edit.js @@ -114,8 +114,12 @@ L.Handler.PolyEdit = L.Handler.extend({ // Check existence of previous and next markers since they wouldn't exist for edge points on the polyline if (marker._prev && marker._next) { this._createMiddleMarker(marker._prev, marker._next); - this._updatePrevNext(marker._prev, marker._next); + } else if (!marker._prev) { + marker._next._middleLeft = null; + } else if (!marker._next) { + marker._prev._middleRight = null; } + this._updatePrevNext(marker._prev, marker._next); // The marker itself is guaranteed to exist and present in the layer, since we managed to click on it this._markerGroup.removeLayer(marker); @@ -196,8 +200,12 @@ L.Handler.PolyEdit = L.Handler.extend({ }, _updatePrevNext: function (marker1, marker2) { - marker1._next = marker2; - marker2._prev = marker1; + if (marker1) { + marker1._next = marker2; + } + if (marker2) { + marker2._prev = marker1; + } }, _getMiddleLatLng: function (marker1, marker2) {