Add optional markers for direct location links
This commit is contained in:
parent
ff716d1036
commit
2e67f22044
@ -528,18 +528,22 @@ mymap.on('moveend', update_hash_from_position);
|
|||||||
mymap.on('dragstart', function () { is_user_drag = 1;});
|
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('keydown', function (e) { if (e.originalEvent.code.match(/Arrow.*/)) is_user_drag = 1;});
|
||||||
mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); });
|
mymap.on('overlayadd', function (e) { update_street_width(); update_outline_visibility(); });
|
||||||
|
|
||||||
function onHashChange(e, hash=null) {
|
function onHashChange(e, hash=null) {
|
||||||
if (!hash)
|
if (!hash)
|
||||||
hash = document.location.hash;
|
hash = document.location.hash;
|
||||||
if (hash == "#" + get_current_location_str())
|
if (hash == "#" + get_current_location_str())
|
||||||
return; // We're already there
|
return; // We're already there
|
||||||
coordstr = hash.slice(1).replace(/%20/g, "").split(",");
|
coordstr = decodeURIComponent(hash.slice(1)).split(",");
|
||||||
if (coordstr.length < 2)
|
if (coordstr.length < 2)
|
||||||
coordstr.push(0); // Default y
|
coordstr.push(0); // Default y
|
||||||
if (coordstr.length < 3)
|
if (coordstr.length < 3)
|
||||||
coordstr.push(mymap.getZoom()); // Default zoom
|
coordstr.push(mymap.getZoom()); // Default zoom
|
||||||
var latlng = L.latLng(parseFloat(coordstr[1]), parseFloat(coordstr[0]));
|
var latlng = L.latLng(parseFloat(coordstr[1]), parseFloat(coordstr[0]));
|
||||||
mymap.setView(latlng, parseInt(coordstr[2]));
|
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);
|
window.addEventListener("hashchange", onHashChange, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user