htdocs: Add trainline support

This commit is contained in:
Markus Koch 2021-02-26 20:08:42 +01:00
parent 1bd7cb1160
commit 8a4a455e05

View File

@ -95,6 +95,14 @@ var style_outlines = {
var style_streets = { var style_streets = {
}; };
var style_trains = {
color: "yellow"
};
var style_tech = {
color: "red"
};
var style_route = { var style_route = {
radius: 8, radius: 8,
fillColor: "#00ff00", fillColor: "#00ff00",
@ -206,9 +214,12 @@ function load_geojson(name, url, geotype, iconcolor, active=1, style={}) {
switch (geotype) { switch (geotype) {
case "street": case "street":
case "train":
onEachFeature = function(feature, layer) { onEachFeature = function(feature, layer) {
layer.myTag = geotype; layer.myTag = geotype;
layer.myName = name; layer.myName = name;
if (geotype == "train")
layer.no_search = true
layer.on("click", function (e) { layer.on("click", function (e) {
current_feature = feature; current_feature = feature;
}); });
@ -387,7 +398,11 @@ function build_sidebar() {
route_element.style.overflow = "scroll"; route_element.style.overflow = "scroll";
route_element.style.padding = "6px"; route_element.style.padding = "6px";
route_element.style.height = "100%"; route_element.style.height = "100%";
route_element.innerHTML = '<a href="#" onclick="toggle_search(\'search\',1);return false;">&lt;-- Return to search<br></a><input style="width:100%;" id="route_start" name="lifo_route_loc" type="search" placeholder="Start at x,y"><br><input style="width:100%;" id="route_destination" name="lifo_route_loc" type="search" placeholder="Go to x,y"><br><input id="route_submit" type="button" style="width:100%;" value="Go!" onclick="route(event)"><div id="route_results"></div>'; route_element.innerHTML = '<a href="#" onclick="toggle_search(\'search\',1);return false;">&lt;-- Return to search<br><br></a>\
<input style="width:100%;" id="route_start" name="lifo_route_loc" type="search" placeholder="Start at x,y"><br>\
<input style="width:100%;" id="route_destination" name="lifo_route_loc" type="search" placeholder="Go to x,y"><br>\
<input type="checkbox" name="use_trains" id="use_trains" value="trains" checked disabled=true><label for="use_trains"> Use trains (only S12)</label><br>\
<input id="route_submit" type="button" style="width:100%;" value="Go!" onclick="route(event)"><div id="route_results"></div>';
} }
} }
@ -451,6 +466,8 @@ function search(e) {
for (key in layers._layers[i].layer._layers) { for (key in layers._layers[i].layer._layers) {
item = layers._layers[i].layer._layers[key]; item = layers._layers[i].layer._layers[key];
if (item.hasOwnProperty("no_search"))
break;
switch (item.feature.geometry.type) { switch (item.feature.geometry.type) {
case "Point": case "Point":
regex = new RegExp(query, 'i'); regex = new RegExp(query, 'i');
@ -533,7 +550,7 @@ function route(e) // BOOKMARK
last_through = ""; last_through = "";
geojson.eachLayer( function(layer) { geojson.eachLayer( function(layer) {
if (last_through != layer.feature.properties.through) { if (last_through != layer.feature.properties.through) {
str += '<li><a href="#" onclick="latLng2 = L.latLng(' + layer.feature.geometry.coordinates[0][1] + ',' + layer.feature.geometry.coordinates[0][0] + '); jump_to(latLng2); return false;">' + htmlEntities(layer.feature.properties.description) + "</a></li>"; str += '<li><a href="#" onclick="latLng2 = L.latLng(' + layer.feature.geometry.coordinates[0][1] + ',' + layer.feature.geometry.coordinates[0][0] + '); jump_to(latLng2); return false;">' + htmlEntities(layer.feature.properties.description).replace('[T]', '🚆️') + "</a></li>";
last_through = layer.feature.properties.through; last_through = layer.feature.properties.through;
} }
}); });