From 8a4a455e05015c3b1cf007b75798aa1ee5aee6b6 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 26 Feb 2021 20:08:42 +0100 Subject: [PATCH] htdocs: Add trainline support --- htdocs/mapscript.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index a27ee10..515ac83 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -95,6 +95,14 @@ var style_outlines = { var style_streets = { }; +var style_trains = { + color: "yellow" + }; + +var style_tech = { + color: "red" + }; + var style_route = { radius: 8, fillColor: "#00ff00", @@ -206,9 +214,12 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) { switch (geotype) { case "street": + case "train": onEachFeature = function(feature, layer) { layer.myTag = geotype; layer.myName = name; + if (geotype == "train") + layer.no_search = true layer.on("click", function (e) { current_feature = feature; }); @@ -387,7 +398,11 @@ function build_sidebar() { route_element.style.overflow = "scroll"; route_element.style.padding = "6px"; route_element.style.height = "100%"; - route_element.innerHTML = '<-- Return to search


'; + route_element.innerHTML = '<-- Return to search

\ +
\ +
\ +
\ +
'; } } @@ -451,6 +466,8 @@ function search(e) { for (key in layers._layers[i].layer._layers) { item = layers._layers[i].layer._layers[key]; + if (item.hasOwnProperty("no_search")) + break; switch (item.feature.geometry.type) { case "Point": regex = new RegExp(query, 'i'); @@ -533,7 +550,7 @@ function route(e) // BOOKMARK last_through = ""; geojson.eachLayer( function(layer) { if (last_through != layer.feature.properties.through) { - str += '
  • ' + htmlEntities(layer.feature.properties.description) + "
  • "; + str += '
  • ' + htmlEntities(layer.feature.properties.description).replace('[T]', '🚆️') + "
  • "; last_through = layer.feature.properties.through; } });