Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polyline pop() not working #199

Open
neel opened this issue May 7, 2020 · 0 comments
Open

Polyline pop() not working #199

neel opened this issue May 7, 2020 · 0 comments

Comments

@neel
Copy link

neel commented May 7, 2020

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant