diff options
author | Markus Koch <markus@notsyncing.net> | 2020-04-26 17:55:32 +0200 |
---|---|---|
committer | Markus Koch <markus@notsyncing.net> | 2020-04-26 17:55:32 +0200 |
commit | 2e67f22044c0629749414c28cc878ba244e7a354 (patch) | |
tree | c1e4844da4a7e169f92784cbccdc86b20ee465c6 | |
parent | ff716d1036d0c1f55ae6b75ef73ef37e93f3220d (diff) | |
download | lifomapserver-2e67f22044c0629749414c28cc878ba244e7a354.tar.gz lifomapserver-2e67f22044c0629749414c28cc878ba244e7a354.tar.bz2 lifomapserver-2e67f22044c0629749414c28cc878ba244e7a354.zip |
Add optional markers for direct location links
-rw-r--r-- | htdocs/mapscript.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index 6b23688..40d48ab 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -528,18 +528,22 @@ mymap.on('moveend', update_hash_from_position); mymap.on('dragstart', function () { is_user_drag = 1;}); mymap.on('keydown', function (e) { if (e.originalEvent.code.match(/Arrow.*/)) is_user_drag = 1;}); mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); }); + function onHashChange(e, hash=null) { if (!hash) hash = document.location.hash; if (hash == "#" + get_current_location_str()) return; // We're already there - coordstr = hash.slice(1).replace(/%20/g, "").split(","); + coordstr = decodeURIComponent(hash.slice(1)).split(","); if (coordstr.length < 2) coordstr.push(0); // Default y if (coordstr.length < 3) coordstr.push(mymap.getZoom()); // Default zoom var latlng = L.latLng(parseFloat(coordstr[1]), parseFloat(coordstr[0])); mymap.setView(latlng, parseInt(coordstr[2])); + if (coordstr.length > 3) { /* Drop named marker */ + foo = L.marker(latlng).bindPopup(htmlEntities(coordstr[3])).addTo(mymap).openPopup(); + } } window.addEventListener("hashchange", onHashChange, false); |