From 0859324a4664e527cc1a5047269379a5d65e93e8 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 19 Apr 2020 09:12:17 +0200 Subject: Add jump-to-coordinates feature and location history --- htdocs/streeteditor.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'htdocs/streeteditor.js') diff --git a/htdocs/streeteditor.js b/htdocs/streeteditor.js index 7109b0e..8b86a4a 100644 --- a/htdocs/streeteditor.js +++ b/htdocs/streeteditor.js @@ -1,6 +1,7 @@ const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); -if (urlParams.has('editor')) { +editor_mode = urlParams.has('editor'); +if (editor_mode) { var draw_layer; var polyline; @@ -60,22 +61,23 @@ if (urlParams.has('editor')) { } } - function onHashChange() { + function editor_onHashChange() { if (("#" + get_location_string()) != window.location.hash) { polyline.remove(mymap); onLoad(0); } } - window.addEventListener("hashchange", onHashChange, false); + window.removeEventListener("hashchange", onHashChange, false); + window.addEventListener("hashchange", editor_onHashChange, false); window.addEventListener("mouseup", onDragEnd, false); // Workaround as polyline.on(dragend, ) doesn't seem to work // Configure map for better editing document.getElementById('mapid').classList.add("no-aa"); mymap.setMaxZoom(14); mymap.off('click', onMapClick); - //mymap.setOpacity(0.7); - + mymap.off('zoomend', update_hash_from_position); + mymap.off('dragend', update_hash_from_position); onLoad(); function get_location_string() { -- cgit v1.2.3