Extended redraw() method to fix behavior during editing

This commit is contained in:
qnstie 2013-07-17 16:16:23 +02:00
parent 9f0d8807df
commit 5acd6d11f4

View File

@ -2,6 +2,7 @@
Geodesic extension to Leaflet library, by Fragger Geodesic extension to Leaflet library, by Fragger
https://github.com/Fragger/Leaflet.Geodesic https://github.com/Fragger/Leaflet.Geodesic
Version from master branch, dated Apr 26, 2013 Version from master branch, dated Apr 26, 2013
Modified by qnstie 2013-07-17 to maintain compatibility with Leaflet.draw
*/ */
(function () { (function () {
function geodesicPoly(Klass, fill) { function geodesicPoly(Klass, fill) {
@ -15,20 +16,21 @@ Version from master branch, dated Apr 26, 2013
}, },
setLatLngs: function (latlngs) { setLatLngs: function (latlngs) {
this._latlngsinit = this._convertLatLngs(latlngs); this._latlngsinit = this._convertLatLngs(latlngs);
this._latlngs = this._convertLatLngs(L.geodesicConvertLines(this._latlngsinit, fill));
return this.redraw(); return this.redraw();
}, },
addLatLng: function (latlng) { addLatLng: function (latlng) {
this._latlngsinit.push(L.latLng(latlng)); this._latlngsinit.push(L.latLng(latlng));
this._latlngs = this._convertLatLngs(L.geodesicConvertLines(this._latlngsinit, fill));
return this.redraw(); return this.redraw();
}, },
spliceLatLngs: function () { // (Number index, Number howMany) spliceLatLngs: function () { // (Number index, Number howMany)
var removed = [].splice.apply(this._latlngsinit, arguments); var removed = [].splice.apply(this._latlngsinit, arguments);
this._convertLatLngs(this._latlngsinit); this._convertLatLngs(this._latlngsinit);
this._latlngs = this._convertLatLngs(L.geodesicConvertLines(this._latlngsinit, fill));
this.redraw(); this.redraw();
return removed; return removed;
},
redraw: function() {
this._latlngs = this._convertLatLngs(L.geodesicConvertLines(this._latlngsinit, fill));
return Klass.prototype.redraw.call(this);
} }
}); });
} }