Merge pull request #1023 from danzel/polyedit

Polyedit fixes for #1022
This commit is contained in:
Dave Leaver 2012-09-30 13:45:49 -07:00
commit 87bc14d968
2 changed files with 12 additions and 3 deletions

View File

@ -31,6 +31,7 @@
map.addLayer(polygon);
var polyline = new L.Polyline([
[51.50, -0.04],
[51.49, -0.02],
[51.51, 0],
[51.52, -0.02]

View File

@ -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) {