add: Form create load

This commit is contained in:
Alexandro Uc Santos
2023-12-07 18:04:17 -06:00
parent 2c74a4b3ae
commit cea26e1f6e
29 changed files with 1292 additions and 59 deletions

View File

@@ -0,0 +1,38 @@
export default function useDirectionRender() {
defineProps({
origin: { type: Object },
destination: { type: Object },
travelMode: { type: String },
})
const directionsRenderer = ref(null);
const directionsService = new window.google.maps.DirectionsService();
onMounted(() => {
directionsRenderer.value = new window.google.maps.DirectionsRenderer();
watch(
() => [props.origin, props.destination, props.travelMode],
() => {
const { origin, destination, travelMode } = props;
if (!origin || !destination || !travelMode) return;
directionsService.route(
{
origin,
destination,
travelMode,
},
(response, status) => {
if (status !== 'OK') return;
directionsRenderer.value.setDirections(response);
}
);
},
{ immediate: true }
);
});
return { directionsRenderer };
}