mirror of
https://gitlab.com/little-lines/frontend.git
synced 2024-11-22 07:36:53 +00:00
implement stop routing
This commit is contained in:
parent
eeccb24a92
commit
760d868dc2
2 changed files with 30 additions and 21 deletions
|
@ -243,7 +243,7 @@ export default {
|
||||||
showRoute: false,
|
showRoute: false,
|
||||||
userLocation: null,
|
userLocation: null,
|
||||||
isLocationRequested: false,
|
isLocationRequested: false,
|
||||||
|
isRouting: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -262,6 +262,10 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
closePopup() {
|
closePopup() {
|
||||||
this.showPopup = false;
|
this.showPopup = false;
|
||||||
|
|
||||||
|
this.$emit('updateRouting', {route:null,isRouting:false});
|
||||||
|
this.isRouting = false;
|
||||||
|
|
||||||
this.onClose();
|
this.onClose();
|
||||||
},
|
},
|
||||||
viewRoute() {
|
viewRoute() {
|
||||||
|
@ -291,8 +295,11 @@ export default {
|
||||||
console.error('Error getting location:', error);
|
console.error('Error getting location:', error);
|
||||||
},
|
},
|
||||||
viewPopup(){
|
viewPopup(){
|
||||||
this.showPopup = true;
|
this.showPopup = true;
|
||||||
this.showRoute = false;
|
this.showRoute = false;
|
||||||
|
|
||||||
|
this.$emit('updateRouting', {route:null,isRouting:false});
|
||||||
|
this.isRouting = false;
|
||||||
},
|
},
|
||||||
addToFavorites() {
|
addToFavorites() {
|
||||||
const currentUser = JSON.parse(sessionStorage.getItem('current_user'));
|
const currentUser = JSON.parse(sessionStorage.getItem('current_user'));
|
||||||
|
@ -333,24 +340,26 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Routing(){
|
Routing(){
|
||||||
console.log('Start routing!!');
|
if(!this.isRouting){
|
||||||
console.log(`nearestStructureData : ${this.nearestStructureData.lon},${this.nearestStructureData.lat}`);
|
console.log('Start routing!!');
|
||||||
console.log(`userLocation : ${this.userLocation.lon},${this.userLocation.lat}`);
|
console.log(`nearestStructureData : ${this.nearestStructureData.lon},${this.nearestStructureData.lat}`);
|
||||||
// Make a request to OpenRouteService API for a sample route
|
console.log(`userLocation : ${this.userLocation.lon},${this.userLocation.lat}`);
|
||||||
const apiKey = import.meta.env.VITE_OPENROUTESERVICE_API_KEY;
|
// Make a request to OpenRouteService API for a sample route
|
||||||
const startCoord = `${this.userLocation.lon},${this.userLocation.lat}`;//'100.53860,13.76410';
|
const apiKey = import.meta.env.VITE_OPENROUTESERVICE_API_KEY;
|
||||||
const endCoord = `${this.nearestStructureData.lon},${this.nearestStructureData.lat}`;//'100.53928,13.76526';
|
const startCoord = `${this.userLocation.lon},${this.userLocation.lat}`;//'100.53860,13.76410';
|
||||||
|
const endCoord = `${this.nearestStructureData.lon},${this.nearestStructureData.lat}`;//'100.53928,13.76526';
|
||||||
|
|
||||||
axios.get(`https://api.openrouteservice.org/v2/directions/wheelchair?api_key=${apiKey}&start=${startCoord}&end=${endCoord}`)
|
axios.get(`https://api.openrouteservice.org/v2/directions/wheelchair?api_key=${apiKey}&start=${startCoord}&end=${endCoord}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const route = response.data.features[0].geometry.coordinates;
|
const route = response.data.features[0].geometry.coordinates;
|
||||||
console.log('This is route :',{route:route})
|
console.log('This is route :',{route:route})
|
||||||
this.$emit('updateRouting', {route:route});
|
this.$emit('updateRouting', {route:route,isRouting:true});
|
||||||
// this.plotRoute(route);
|
this.isRouting = true;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('Error fetching route:', error);
|
console.error('Error fetching route:', error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ const closePopup = () => {
|
||||||
const handleRouting = (res) => {
|
const handleRouting = (res) => {
|
||||||
console.log("Received Route:", res);
|
console.log("Received Route:", res);
|
||||||
route.value = res.route;
|
route.value = res.route;
|
||||||
isRouting.value = true;
|
isRouting.value = res.isRouting;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue