fixes: directions api change
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import useDirectionsRender from '../composables/useDirectionRender';
|
||||
import Cardload from './CardLoad.vue';
|
||||
import { useLoadsStore } from '../stores/loads';
|
||||
import { useNotificationsStore } from '../stores/notifications';
|
||||
|
||||
const mapKey = import.meta.env.VITE_MAP_KEY;
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
const vehicleLastLocation = ref(null);
|
||||
const isLoadActive = ref(false);
|
||||
|
||||
const { geocodeAddress, getDirections } = useDirectionsRender()
|
||||
const { getDirections } = useDirectionsRender()
|
||||
|
||||
const props = defineProps({
|
||||
proposal: {
|
||||
@@ -32,6 +33,7 @@
|
||||
|
||||
defineEmits(['reset-proposal'])
|
||||
const loadStore = useLoadsStore();
|
||||
const notyStore = useNotificationsStore();
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('resize', handleResize);
|
||||
@@ -44,36 +46,53 @@
|
||||
});
|
||||
|
||||
const initData = async() => {
|
||||
console.log(props.proposal)
|
||||
isLoading.value = true;
|
||||
const code = props.proposal.load.shipment_code;
|
||||
const filter = "?shipment_code[$in]=" + code;
|
||||
const resp = await loadStore.getLoad(filter);
|
||||
console.log(resp);
|
||||
if(resp.total > 0) {
|
||||
load.value = resp.data[0];
|
||||
originCoords.value = await geocodeAddress(load.value.origin_formatted_address);
|
||||
destinationCoords.value = await geocodeAddress(load.value.destination_formatted_address);
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
if(load.value.vehicle) {
|
||||
vehicleLastLocation.value = {
|
||||
lat: parseFloat(load.value.vehicle.last_location_lat),
|
||||
lng: parseFloat(load.value.vehicle.last_location_lng)
|
||||
try {
|
||||
const addressOrigin = load.value?.origin;
|
||||
const addressDestination = load.value?.destination;
|
||||
if(addressOrigin && addressDestination) {
|
||||
originCoords.value = {lat: Number.parseFloat(addressOrigin.lat), lng: Number.parseFloat(addressOrigin.lng)};
|
||||
destinationCoords.value = {lat: Number.parseFloat(addressDestination.lat), lng: Number.parseFloat(addressDestination.lng)};
|
||||
|
||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
switch (load.value.load_status) {
|
||||
case 'Loading':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
case 'Transit':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
case 'Downloading':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
isLoadActive.value = false;
|
||||
break;
|
||||
|
||||
if(load.value.vehicle) {
|
||||
vehicleLastLocation.value = {
|
||||
lat: parseFloat(load.value.vehicle.last_location_lat),
|
||||
lng: parseFloat(load.value.vehicle.last_location_lng)
|
||||
}
|
||||
}
|
||||
|
||||
switch (load.value.load_status) {
|
||||
case 'Loading':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
case 'Transit':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
case 'Downloading':
|
||||
isLoadActive.value = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
isLoadActive.value = false;
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
notyStore.$patch({
|
||||
text : 'No se pudo cargar mapa',
|
||||
show : true,
|
||||
error: true
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -140,7 +159,6 @@
|
||||
:draggable="false"
|
||||
>
|
||||
<div style="text-align: center">
|
||||
<!-- <img src="/images/freeTruck.png" width="25" height="25" /> -->
|
||||
<i class="fa-solid fa-truck" :style="{fontSize: 25 + 'px', color: 'green'}"></i>
|
||||
</div>
|
||||
</CustomMarker>
|
||||
@@ -148,7 +166,6 @@
|
||||
v-if="polylines"
|
||||
:options="{
|
||||
path: polylines,
|
||||
// geodesic: true,
|
||||
strokeColor: '#2D90BB',
|
||||
strokeOpacity: 0.7,
|
||||
strokeWeight: 5,
|
||||
|
||||
Reference in New Issue
Block a user