Leaflet / Leaflet.Editable

Make geometries editable in Leaflet.
http://leaflet.github.io/Leaflet.Editable/doc/api.html
553 stars 198 forks source link

Polyline pop() not working #199

Open neel opened 4 years ago

neel commented 4 years ago

I am trying to clear all points in the polyline

while(!this._route.isEmpty()){
    this._route.editor.pop();
}

getting exception

TypeError: Cannot read property 'length' of undefined
    at e.pop (map.js:12)
    at a.clear (map.js:12)

The Leaflet.Editable pop() function doesn't get _drawnLatLngs

pop: function () {
            if (this._drawnLatLngs.length <= 1) return;
            var latlng;
            if (this._drawing === L.Editable.FORWARD) latlng = this._drawnLatLngs[this._drawnLatLngs.length - 1];
            else latlng = this._drawnLatLngs[0];
            this.removeLatLng(latlng);
            if (this._drawing === L.Editable.FORWARD) this.tools.anchorForwardLineGuide(this._drawnLatLngs[this._drawnLatLngs.length - 1]);
            else this.tools.anchorForwardLineGuide(this._drawnLatLngs[0]);
            return latlng;
        },

How to fix ?