fix: geocode locations
This commit is contained in:
@@ -79,7 +79,6 @@
|
|||||||
formLoad.owner = auth.user?.first_name + ' ' + auth.user?.last_name;
|
formLoad.owner = auth.user?.first_name + ' ' + auth.user?.last_name;
|
||||||
//origin_formatted_address
|
//origin_formatted_address
|
||||||
if(loadStore.currentLoad){
|
if(loadStore.currentLoad){
|
||||||
console.log(loadStore.currentLoad);
|
|
||||||
formLoad.price = loadStore.currentLoad.actual_cost;
|
formLoad.price = loadStore.currentLoad.actual_cost;
|
||||||
formLoad.segment = loadStore.currentLoad.categories?.length <= 0 ? [] : loadStore.currentLoad.categories.map(m =>{
|
formLoad.segment = loadStore.currentLoad.categories?.length <= 0 ? [] : loadStore.currentLoad.categories.map(m =>{
|
||||||
return m;
|
return m;
|
||||||
@@ -131,7 +130,6 @@
|
|||||||
|
|
||||||
watch([originCoords, destinationCoords], async() => {
|
watch([originCoords, destinationCoords], async() => {
|
||||||
if(originCoords.value && destinationCoords.value) {
|
if(originCoords.value && destinationCoords.value) {
|
||||||
// console.log('Se llama api direcciones ')
|
|
||||||
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
polylines.value = await getDirections(originCoords.value, destinationCoords.value);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -406,7 +404,7 @@
|
|||||||
v-model:field="formLoad.dateDownload"
|
v-model:field="formLoad.dateDownload"
|
||||||
/>
|
/>
|
||||||
<Custominput
|
<Custominput
|
||||||
label="Peso de la carga*"
|
label="Peso de la carga en Kg*"
|
||||||
type="number"
|
type="number"
|
||||||
:filled="false"
|
:filled="false"
|
||||||
name="weight"
|
name="weight"
|
||||||
@@ -423,7 +421,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Custominput
|
<Custominput
|
||||||
label="Precio"
|
label="Precio en MXN"
|
||||||
type="Number"
|
type="Number"
|
||||||
:filled="false"
|
:filled="false"
|
||||||
name="price"
|
name="price"
|
||||||
@@ -451,8 +449,8 @@
|
|||||||
<h2>Dirección de origen</h2>
|
<h2>Dirección de origen</h2>
|
||||||
|
|
||||||
<div class="form-check my-4" v-if="loadingLocations === false">
|
<div class="form-check my-4" v-if="loadingLocations === false">
|
||||||
<input class="form-check-input chekmark" type="checkbox" id="flexCheckDefault" v-model="checkLocationLoad">
|
<input class="form-check-input chekmark" type="checkbox" id="directoryOrigin" v-model="checkLocationLoad">
|
||||||
<label class="form-check-label custom-label" for="flexCheckDefault">
|
<label class="form-check-label custom-label" for="directoryOrigin">
|
||||||
Usar locaciones registradas
|
Usar locaciones registradas
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@@ -521,8 +519,8 @@
|
|||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<h2>Dirección de destino</h2>
|
<h2>Dirección de destino</h2>
|
||||||
<div class="form-check my-4" v-if="loadingLocations === false">
|
<div class="form-check my-4" v-if="loadingLocations === false">
|
||||||
<input class="form-check-input chekmark" type="checkbox" id="flexCheckDefault" v-model="checkLocationDownload">
|
<input class="form-check-input chekmark" type="checkbox" id="directoryDestination" v-model="checkLocationDownload">
|
||||||
<label class="form-check-label custom-label" for="flexCheckDefault">
|
<label class="form-check-label custom-label" for="directoryDestination">
|
||||||
Usar locaciones registradas
|
Usar locaciones registradas
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,31 +7,39 @@ export default function useDirectionsRender() {
|
|||||||
|
|
||||||
const originCoords = ref(null);
|
const originCoords = ref(null);
|
||||||
const destinationCoords = ref(null);
|
const destinationCoords = ref(null);
|
||||||
// const polylines = ref([]);
|
|
||||||
|
// const geocodeAddress = async (address) => {
|
||||||
|
// try {
|
||||||
|
// const response = await fetch(
|
||||||
|
// `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(
|
||||||
|
// address
|
||||||
|
// )}&key=${mapKey}`
|
||||||
|
// );
|
||||||
|
// const data = await response.json();
|
||||||
|
// const location = data.results[0].geometry.location;
|
||||||
|
// return location;
|
||||||
|
// } catch (error) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
const geocodeAddress = async (address) => {
|
const geocodeAddress = async (address) => {
|
||||||
// Utiliza la API de geocodificación de Google Maps para obtener las coordenadas
|
|
||||||
// const apiKey = 'AIzaSyAJtfvrAKy7vnUSv2nzk4dYQkOs3OP4MMs'; // Reemplaza con tu clave de API
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const geocoder = new google.maps.Geocoder();
|
||||||
`https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(
|
console.log(address)
|
||||||
address
|
const data = await geocoder.geocode({ address: address });
|
||||||
)}&key=${mapKey}`
|
const latitude = data.results[0].geometry.location.lat();
|
||||||
);
|
const longitude = data.results[0].geometry.location.lng();
|
||||||
const data = await response.json();
|
return {lng: longitude, lat: latitude};
|
||||||
const location = data.results[0].geometry.location;
|
|
||||||
return location;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log('Error location', error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getDirections = async (originCoords, destinationCoords) => {
|
const getDirections = async (originCoords, destinationCoords) => {
|
||||||
// const originLatLng = `${originCoords.lat},${originCoords.lng}`;
|
|
||||||
// const destinationLatLng = `${destinationCoords.lat},${destinationCoords.lng}`;
|
|
||||||
try {
|
try {
|
||||||
const directionsService = new google.maps.DirectionsService();
|
const directionsService = new google.maps.DirectionsService();
|
||||||
// const origin = google.maps.LatLng(originCoords.lat, originCoords.lng)
|
|
||||||
// const destination = google.maps.LatLng(destinationCoords.lat, destinationCoords.lng)
|
|
||||||
const request = {
|
const request = {
|
||||||
origin: {lat: Number.parseFloat(originCoords.lat), lng: Number.parseFloat(originCoords.lng)},
|
origin: {lat: Number.parseFloat(originCoords.lat), lng: Number.parseFloat(originCoords.lng)},
|
||||||
destination: {lat: Number.parseFloat(destinationCoords.lat), lng: Number.parseFloat(destinationCoords.lng)},
|
destination: {lat: Number.parseFloat(destinationCoords.lat), lng: Number.parseFloat(destinationCoords.lng)},
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ export const login = async(body) => {
|
|||||||
console.log('auth: ', data);
|
console.log('auth: ', data);
|
||||||
if(data.accessToken !== null){
|
if(data.accessToken !== null){
|
||||||
if(data.user.job_role !== 'driver'){
|
if(data.user.job_role !== 'driver'){
|
||||||
//TODO: Guardar token y datos del usuario
|
|
||||||
return {
|
return {
|
||||||
msg: 'success',
|
msg: 'success',
|
||||||
data
|
data
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
console.log(load.value.load_status);
|
console.log(load.value);
|
||||||
switch (load.value.load_status) {
|
switch (load.value.load_status) {
|
||||||
case 'Loading':
|
case 'Loading':
|
||||||
isLoadActive.value = true;
|
isLoadActive.value = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user