From 8ca10033f92924581b3713291bec90cb8b91cb4c Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 19 Apr 2020 20:42:45 +0200 Subject: editor: Make polyline clearable --- htdocs/streeteditor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js index 5d69d0b..fea2b36 100644 --- a/htdocs/streeteditor.js +++ b/htdocs/streeteditor.js @@ -41,6 +41,10 @@ if (editor_mode) { } function onLoad(interactive = 1) { + if (polyline) { + polyline.remove(mymap); + polyline = undefined; + } if (interactive) { str = prompt("Instructions: \n" + "* Click the scribble-icon in the top left to start or continue drawing.\n" + @@ -57,8 +61,6 @@ if (editor_mode) { for (var i = 0; i < coords.length; i++) { coords[i] = [coords[i][1], coords[i][0]]; } - if (polyline) - polyline.remove(mymap); polyline = L.polyline(coords).addTo(mymap); // polyline.on('dragend', onDragEnd); // TODO: Doesn't work, see "workaround" below polyline.enableEdit(); -- cgit v1.2.3