Mark markers markers that are not on a way in dark red
This commit is contained in:
parent
67784097ae
commit
13a7414798
2 changed files with 17 additions and 5 deletions
|
@ -139,8 +139,9 @@ function addGeoJsonToMap(dat) {
|
|||
|
||||
async function updateBrouter () {
|
||||
if (markers.length > 0) {
|
||||
for (i=1; i< markers.length-1; i++) {
|
||||
for (i=0; i< markers.length; i++) {
|
||||
markers[i]._icon.classList.remove("red");
|
||||
markers[i]._icon.classList.remove("darkred");
|
||||
}
|
||||
markers[markers.length-1]._icon.classList.add("red");
|
||||
markers[0]._icon.classList.add("green");
|
||||
|
@ -156,16 +157,26 @@ async function updateBrouter () {
|
|||
const marker1 = markers[i].getLatLng();
|
||||
const marker2 = markers[i+1].getLatLng();
|
||||
const url = `https://brouter.de/brouter?lonlats=${marker1.lng},${marker1.lat}|${marker2.lng},${marker2.lat}&profile=rail&alternativeidx=0&format=geojson`;
|
||||
fetch(url).then((response) => response.json())
|
||||
.then((data) => {
|
||||
fetch(url).then((response) => {
|
||||
if (geojson != undefined) {
|
||||
map.removeLayer(geojson);
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error("HTTP error " + response.status);
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.then((data) => {
|
||||
delete data.features[0].properties.messages
|
||||
geojsons.push(data.features[0]);
|
||||
const dat = {type: "FeatureCollection", features: geojsons};
|
||||
geojson = addGeoJsonToMap(dat);
|
||||
})
|
||||
.catch(err => {
|
||||
markers[i]._icon.classList.add("darkred");
|
||||
markers[i+1]._icon.classList.add("darkred");
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,3 +21,4 @@ body {
|
|||
}
|
||||
img.red { filter: hue-rotate(120deg); }
|
||||
img.green { filter: hue-rotate(-120deg); }
|
||||
img.darkred { filter: hue-rotate(160deg); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue