summaryrefslogtreecommitdiff
path: root/htdocs/mapscript.js
diff options
context:
space:
mode:
authorMarkus Koch <markus@notsyncing.net>2021-12-27 11:54:29 +0100
committerMarkus Koch <markus@notsyncing.net>2021-12-27 11:54:29 +0100
commit66e80778a90f6e846f304b7a5319a64a9dcca359 (patch)
tree9b9fae4e79dfa302ea1e5d1a198e6260a94cfd5a /htdocs/mapscript.js
parentb5fd6aab1f68683675843a0a18352492af959fb7 (diff)
downloadlifomapserver-66e80778a90f6e846f304b7a5319a64a9dcca359.tar.gz
lifomapserver-66e80778a90f6e846f304b7a5319a64a9dcca359.tar.bz2
lifomapserver-66e80778a90f6e846f304b7a5319a64a9dcca359.zip
htdocs: Link streets, cities, rivers, oceans, ... to the wiki
Diffstat (limited to 'htdocs/mapscript.js')
-rw-r--r--htdocs/mapscript.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js
index cf45304..cf7066a 100644
--- a/htdocs/mapscript.js
+++ b/htdocs/mapscript.js
@@ -214,6 +214,7 @@ function load_tiles(name, id) {
var current_location = "";
var current_feature = null;
+var current_layer = null;
function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
var xhttp_ps = new XMLHttpRequest();
xhttp_ps.onreadystatechange = function() {
@@ -232,6 +233,7 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
if (geotype == "train")
layer.no_search = true
layer.on("click", function (e) {
+ current_layer = layer;
current_feature = feature;
});
};
@@ -684,19 +686,29 @@ var baseballIcon = L.AwesomeMarkers.icon({
markerColor: 'red'
});
+function escapeHtml(text) {
+ return text
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/"/g, "&quot;")
+ .replace(/'/g, "&#039;");
+}
+
function onMapClick(e) {
var addinfo = "";
pos = resolve_latlng(e.latlng);
route_links = '<br><a href="#" onclick="latLng2 = L.latLng(' + pos.lng + ',' + pos.lat + '); set_route_start(latLng2); return false;">[route from here]</a>';
route_links += ' <a href="#" onclick="latLng2 = L.latLng(' + pos.lng + ',' + pos.lat + '); set_route_destination(latLng2); return false;">[route to here]</a>';
if (current_location != "")
- addinfo = " (part of <a target=\"_blank\" href='" + wikiurl_base + current_location + "'>" + current_location + "</a>)";
+ addinfo = " (part of <a target=\"_blank\" href=\"" + wikiurl_base + encodeURIComponent(current_location) + "\">" + escapeHtml(current_location) + "</a>)";
if (current_feature) {
- popup.setLatLng(e.latlng).setContent("This is " + current_feature.properties.name + addinfo + route_links).openOn(mymap);
+ popup.setLatLng(e.latlng).setContent("This is <a target=\"_blank\" href=\"" + wikiurl_base + current_layer.myName + ":" + encodeURIComponent(current_feature.properties.name) + "\">" + escapeHtml(current_feature.properties.name) + "</a>" + addinfo + route_links).openOn(mymap);
} else {
popup.setLatLng(e.latlng).setContent("You clicked the map at " + pos.lng + "," + pos.lat + addinfo + route_links).openOn(mymap);
}
current_feature = null;
+ current_layer = null;
current_location = "";
}