diff options
author | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2020-07-02 18:43:05 +0200 |
---|---|---|
committer | Gabriel Pérez-Cerezo <gabriel@gpcf.eu> | 2020-07-02 18:43:05 +0200 |
commit | 5a75bd30a6a230d0d5364faaa85ea3285e21dac9 (patch) | |
tree | 6d93c8f367196422770620028fce60cb98e84abe | |
parent | 6eb21fd1caf4c24895b51f1c424e0c03afe2a232 (diff) | |
download | lifomapserver-5a75bd30a6a230d0d5364faaa85ea3285e21dac9.tar.gz lifomapserver-5a75bd30a6a230d0d5364faaa85ea3285e21dac9.tar.bz2 lifomapserver-5a75bd30a6a230d0d5364faaa85ea3285e21dac9.zip |
Correctly handle TCB sides, prepare form for routing functions
-rw-r--r-- | htdocs/index.html | 9 | ||||
-rw-r--r-- | htdocs/mapscript.js | 72 |
2 files changed, 50 insertions, 31 deletions
diff --git a/htdocs/index.html b/htdocs/index.html index 4fa05a4..8aff308 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -42,6 +42,15 @@ background-color: #afa; } + h4 { + margin-bottom: 0.2em; + } + + .autoroute { + background-color: #aaf; + } + + td { border-bottom: 2px solid black; } diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index 543aec9..38b336c 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -208,13 +208,10 @@ var signalMarkerOptions = { }; -sig_ids = {} function go_to_signal(ps) { - console.log(ps) - if (sig_ids[ps]) { - console.log("signal!!") - sig_ids[ps].openPopup() + if (signals[ps]) { + signals[ps].layer.openPopup() } } @@ -232,39 +229,52 @@ function load_signals() { var json = []; for (var m in signals) { - console.log(m); json.push(signals[m]); } onEachFeature = function(feature, layer) { label = String(feature.properties.name); - sig_ids[feature.properties.pos] = layer - var routes = feature.properties.routes; - var s = '<table style="width: 100%"><thead><tr><td>Name<td>RC<td>LN</thead>'; - for (i=0;i<routes.length;i++) { - var r = routes[i]; - var rstyle="route" - var ln = "" - var rc = "" - if (r.ars["default"]) { - rstyle="defroute" - r.ars.LN.push("*") - r.ars.RC.push("*") + signals[feature.properties.pos].layer = layer + var sides = feature.properties.sides; + var l = ["A","B"] + var s = "" + for (var i in sides) { + var side = sides[i] + var routes = sides[i].routes + if (routes.length < 1) { + continue } - if (r.ars.LN ) { - ln = r.ars.LN.join("<br>") - } - if (r.ars.RC ) { - rc = r.ars.RC.join("<br>") - } - var name = r.name - if (r.endpoint) { - var e = r.endpoint.split(",") - name = '<a href="#" onclick="latLng2 = L.latLng(' + e[2] + ',' + e[0] + '); jump_to(latLng2); go_to_signal(\''+r.endpoint+'\'); return false;">'+r.name+"</a>" + s = s + "<h4>Side "+l[i]+": "+side.signal_name+"</h4>" + s = s + '<table style="width: 100%"><thead><tr><td>Name<td>RC<td>LN</thead>'; + for (var i=0;i<routes.length;i++) { + var r = routes[i]; + var rstyle="route" + var ln = "" + var rc = "" + if (r.ars["default"]) { + rstyle="defroute" + r.ars.LN.push("*") + r.ars.RC.push("*") + } + if (r.auto) { + rstyle="autoroute" + } + if (r.ars.LN ) { + ln = r.ars.LN.join("<br>") + } + if (r.ars.RC ) { + rc = r.ars.RC.join("<br>") + } + var name = r.name + if (r.endpoint) { + var e = r.endpoint.split(",") + name = '<a href="#" onclick="latLng2 = L.latLng(' + e[2] + ',' + e[0] + '); jump_to(latLng2); go_to_signal(\''+r.endpoint+'\','+r.endpoint_side+'); return false;">'+r.name+"</a>" + } + s = s+ '<tr class="'+rstyle+'"><td>'+name+"<td>"+rc+"<td>"+ln+"</tr>"; } - s = s+ '<tr class="'+rstyle+'"><td>'+name+"<td>"+ln+"<td>"+rc+"</tr>"; + s = s + '</table><form><input type="text" name="route'+l[i]+'rc" placeholder="RC" style="width: 100%"></input><input type="text" name="route'+l[i]+'ln" placeholder="LN" style="width: 40%"></input><input type="submit" name="route'+l[i]+'submit" value="Next Signal"></input></form>' } - layer.bindPopup('<h1>Routes here:</h1>' + s + "</table>"); + layer.bindPopup('<h1>Routes here:</h1>' + s ); }; pointToLayer = function (feature, latlng) { @@ -276,7 +286,7 @@ function load_signals() { pointToLayer: pointToLayer, filter: filter }); - layers.addOverlay(geojson, name); + layers.addOverlay(geojson, "Signals"); if (active) geojson.addTo(mymap); |