Bugfix: refresh the path correctly
This commit is contained in:
parent
13a7414798
commit
13900c8092
1 changed files with 6 additions and 6 deletions
|
@ -147,10 +147,10 @@ async function updateBrouter () {
|
||||||
markers[0]._icon.classList.add("green");
|
markers[0]._icon.classList.add("green");
|
||||||
}
|
}
|
||||||
geojsons = [];
|
geojsons = [];
|
||||||
if (markers.length < 2) {
|
|
||||||
if (geojson != undefined) {
|
if (geojson != undefined) {
|
||||||
map.removeLayer(geojson);
|
map.removeLayer(geojson);
|
||||||
}
|
}
|
||||||
|
if (markers.length < 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let i = 0; i < markers.length - 1 ; i++) {
|
for (let i = 0; i < markers.length - 1 ; i++) {
|
||||||
|
@ -158,15 +158,15 @@ async function updateBrouter () {
|
||||||
const marker2 = markers[i+1].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`;
|
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) => {
|
fetch(url).then((response) => {
|
||||||
if (geojson != undefined) {
|
|
||||||
map.removeLayer(geojson);
|
|
||||||
}
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("HTTP error " + response.status);
|
throw new Error("HTTP error " + response.status);
|
||||||
}
|
}
|
||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
if (geojson != undefined) {
|
||||||
|
map.removeLayer(geojson);
|
||||||
|
}
|
||||||
delete data.features[0].properties.messages
|
delete data.features[0].properties.messages
|
||||||
geojsons.push(data.features[0]);
|
geojsons.push(data.features[0]);
|
||||||
const dat = {type: "FeatureCollection", features: geojsons};
|
const dat = {type: "FeatureCollection", features: geojsons};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue