diff --git a/src/components/FormLoadModal.vue b/src/components/FormLoadModal.vue index 4c7719b..4ee14d2 100644 --- a/src/components/FormLoadModal.vue +++ b/src/components/FormLoadModal.vue @@ -24,12 +24,13 @@ const heightMap = ref(768); const originCoords = ref(null); const destinationCoords = ref(null); + const polylines = ref([]); const startLocation = ref(null); const endLocation = ref(null); const isLoading = ref(false); const loadingLocations = ref(false); const submited = ref(false); - const { geocodeAddress } = useDirectionsRender(); + const { geocodeAddress, getDirections } = useDirectionsRender(); const formRef = ref(null); const filterQueryVehicles = ref([]); const checkLocationLoad = ref(false); @@ -46,6 +47,8 @@ stateDestination: null, }); + const mapKey = import.meta.env.VITE_MAP_KEY; + const clearLoad = () => { loadStore.currentLoad = null; @@ -124,6 +127,13 @@ destinationCoords.value = await geocodeAddress(endLocation.value); } }) + + watch([originCoords, destinationCoords], async() => { + if(originCoords.value && destinationCoords.value) { + console.log('Se llama api direcciones ') + polylines.value = await getDirections(originCoords.value, destinationCoords.value); + } + }) }) watch(locationLoadSelected, () => { @@ -510,7 +520,7 @@ v-model="locationDownloadSelected" > - + - + diff --git a/src/components/MakeProposalModal.vue b/src/components/MakeProposalModal.vue index 4c4abae..d477276 100644 --- a/src/components/MakeProposalModal.vue +++ b/src/components/MakeProposalModal.vue @@ -3,7 +3,7 @@ import CardEmpty from './CardEmpty.vue'; import Spiner from './ui/Spiner.vue'; import BadgeError from './ui/BadgeError.vue'; - import { GoogleMap, Marker } from 'vue3-google-map'; + import { GoogleMap, Marker, Polyline } from 'vue3-google-map'; import useDirectionsRender from '../composables/useDirectionRender'; import { useAuthStore } from '../stores/auth'; import { useCompanyStore } from '../stores/company'; @@ -11,11 +11,13 @@ import { saveProposal } from '../services/vehicles' import Swal from 'sweetalert2'; + const mapKey = import.meta.env.VITE_MAP_KEY; const zoom = ref(6); const heightMap = ref(768); const originCoords = ref(null); const destinationCoords = ref(null); + const polylines = ref([]); const isLoading = ref(false); const loadingSubmit = ref(false); const windowWidth = ref(window.innerWidth); @@ -28,7 +30,7 @@ comments: '', }); - const { geocodeAddress } = useDirectionsRender() + const { geocodeAddress, getDirections } = useDirectionsRender() const props = defineProps({ load: { @@ -61,6 +63,7 @@ await vehiclesStore.fetchVehicles(filterQuery); originCoords.value = await geocodeAddress(props.load.origin_formatted_address); destinationCoords.value = await geocodeAddress(props.load.destination_formatted_address); + polylines.value = await getDirections(originCoords.value, destinationCoords.value); isLoading.value = false; console.log(props.proposal); if(props.proposal) { @@ -204,7 +207,7 @@ - + diff --git a/src/components/MapDirections.vue b/src/components/MapDirections.vue index 6502a99..3765211 100644 --- a/src/components/MapDirections.vue +++ b/src/components/MapDirections.vue @@ -10,6 +10,7 @@ const polyline = ref([]); // const startLocation = ref({ lat: 37.7749, lng: -122.4194 }); // San Francisco // const endLocation = ref({ lat: 34.0522, lng: -118.2437 }); // Los Angeles + const mapKey = import.meta.env.VITE_MAP_KEY; onMounted(async() => { window.addEventListener('resize', handleResize); @@ -80,7 +81,7 @@