mirror of
https://github.com/KevinMidboe/nova-map-fields.git
synced 2025-10-29 17:50:27 +00:00
Transform navigation response before bubbling input latlng
This commit is contained in:
2
dist/js/field.js
vendored
2
dist/js/field.js
vendored
File diff suppressed because one or more lines are too long
@@ -39,18 +39,24 @@ export default {
|
|||||||
const cords =
|
const cords =
|
||||||
"6.985908836799895,61.28541170467011;7.092996407603286,61.23027059410228;10.761970380502788,59.927108594277456";
|
"6.985908836799895,61.28541170467011;7.092996407603286,61.23027059410228;10.761970380502788,59.927108594277456";
|
||||||
const URL = `https://api.mapbox.com/directions/v5/mapbox/driving/${cords}?geometries=geojson&access_token=pk.eyJ1Ijoia2V2aW5taWRib2UiLCJhIjoiY2pydWhlamQyMHJ2NTRhdGN1em5ndXVyMyJ9.Ejdo_3iuuGOD662Bh6es4w`;
|
const URL = `https://api.mapbox.com/directions/v5/mapbox/driving/${cords}?geometries=geojson&access_token=pk.eyJ1Ijoia2V2aW5taWRib2UiLCJhIjoiY2pydWhlamQyMHJ2NTRhdGN1em5ndXVyMyJ9.Ejdo_3iuuGOD662Bh6es4w`;
|
||||||
fetch(URL)
|
return fetch(URL)
|
||||||
.then((resp) => resp.json())
|
.then((resp) => resp.json())
|
||||||
.then((response) => {
|
.then((response) => response.routes[0].geometry)
|
||||||
const { coordinates } = response.routes.geometry;
|
.then(this.mapNavigationRoute);
|
||||||
console.log("got coordinates:", coordinates);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
triggerChange(markers) {
|
mapNavigationRoute(coords) {
|
||||||
|
return coords.map(([lng, lat]) => {
|
||||||
|
return { lat, lng };
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async triggerChange(markers) {
|
||||||
console.log("forwarding markers:", markers);
|
console.log("forwarding markers:", markers);
|
||||||
this.queryNavigation(markers);
|
const navigationRouteCoords = await this.queryNavigation(markers);
|
||||||
this.$emit("input", markers);
|
console.log("got navigationRouteCoords:", navigationRouteCoords);
|
||||||
|
|
||||||
|
this.$emit("input", navigationRouteCoords);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user