Dynamic cords from markers

This commit is contained in:
2021-09-06 16:24:45 +02:00
parent 8c8c21b432
commit 0debcb02a1
2 changed files with 9 additions and 3 deletions

2
dist/js/field.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -36,8 +36,10 @@ export default {
methods: {
queryNavigation(markers) {
const cords =
"6.985908836799895,61.28541170467011;7.092996407603286,61.23027059410228;10.761970380502788,59.927108594277456";
const cords = markers
.map((marker) => `${marker.lng},${marker.lat};`)
.slice(0, -1);
const URL = `https://api.mapbox.com/directions/v5/mapbox/driving/${cords}?geometries=geojson&access_token=pk.eyJ1Ijoia2V2aW5taWRib2UiLCJhIjoiY2pydWhlamQyMHJ2NTRhdGN1em5ndXVyMyJ9.Ejdo_3iuuGOD662Bh6es4w`;
return fetch(URL)
.then((resp) => resp.json())
@@ -52,6 +54,10 @@ export default {
},
async triggerChange(markers) {
if (markers.length === 0) {
return;
}
console.log("forwarding markers:", markers);
const navigationRouteCoords = await this.queryNavigation(markers);
console.log("got navigationRouteCoords:", navigationRouteCoords);