fix: correct Routes API service usage and fix bus stops missing markers
This commit is contained in:
@ -41,7 +41,8 @@ export function useDirectionsRoute() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Importar librerías necesarias de la nueva API
|
// Importar librerías necesarias de la nueva API
|
||||||
const { Route } = await google.maps.importLibrary("routes") as any;
|
const { RoutesService } = await google.maps.importLibrary("routes") as any;
|
||||||
|
const routeService = new RoutesService();
|
||||||
|
|
||||||
// Límite de la API de Google Maps Routes: Origen, Destino, y hasta 25 intermediates
|
// Límite de la API de Google Maps Routes: Origen, Destino, y hasta 25 intermediates
|
||||||
const maxPuntosPorChunk = 25;
|
const maxPuntosPorChunk = 25;
|
||||||
@ -79,7 +80,7 @@ export function useDirectionsRoute() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await Route.computeRoutes({
|
const response = await routeService.computeRoutes({
|
||||||
origin,
|
origin,
|
||||||
destination,
|
destination,
|
||||||
intermediates,
|
intermediates,
|
||||||
|
|||||||
@ -417,7 +417,8 @@ export function useGoogleMaps() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Cargar ruta
|
// Cargar ruta
|
||||||
const { Route } = await google.maps.importLibrary("routes") as any;
|
const { RoutesService } = await google.maps.importLibrary("routes") as any;
|
||||||
|
const routeService = new RoutesService();
|
||||||
|
|
||||||
const tamañoChunk = 25;
|
const tamañoChunk = 25;
|
||||||
|
|
||||||
@ -451,7 +452,7 @@ export function useGoogleMaps() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await Route.computeRoutes({
|
const response = await routeService.computeRoutes({
|
||||||
origin,
|
origin,
|
||||||
destination,
|
destination,
|
||||||
intermediates,
|
intermediates,
|
||||||
|
|||||||
@ -56,11 +56,12 @@ export function useParadaCercana() {
|
|||||||
let mejorRutaPuntos: google.maps.LatLng[] = [];
|
let mejorRutaPuntos: google.maps.LatLng[] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { Route } = await google.maps.importLibrary("routes") as any;
|
const { RoutesService } = await google.maps.importLibrary("routes") as any;
|
||||||
|
const routeService = new RoutesService();
|
||||||
|
|
||||||
for (const stop of top5) {
|
for (const stop of top5) {
|
||||||
try {
|
try {
|
||||||
const response = await Route.computeRoutes({
|
const response = await routeService.computeRoutes({
|
||||||
origin: {
|
origin: {
|
||||||
location: {
|
location: {
|
||||||
latLng: {
|
latLng: {
|
||||||
|
|||||||
@ -406,11 +406,13 @@ function clearMapMarkers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function updateMapMarkers() {
|
async function updateMapMarkers() {
|
||||||
if (!isLoaded.value || !map.value) return;
|
if (!isLoaded.value || !map.value || isUpdatingMarkers.value) return;
|
||||||
|
|
||||||
|
isUpdatingMarkers.value = true;
|
||||||
const currentRequestRouteId = routeStore.selectedRouteId;
|
const currentRequestRouteId = routeStore.selectedRouteId;
|
||||||
const stops = [...routeStore.selectedRouteStops];
|
const stops = [...routeStore.selectedRouteStops];
|
||||||
|
|
||||||
|
try {
|
||||||
if (!currentRequestRouteId || stops.length === 0) {
|
if (!currentRequestRouteId || stops.length === 0) {
|
||||||
clearMapMarkers();
|
clearMapMarkers();
|
||||||
return;
|
return;
|
||||||
@ -428,8 +430,6 @@ async function updateMapMarkers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Agregar todos los stops como marcadores 'normales' para que se vean en el mapa
|
// Agregar todos los stops como marcadores 'normales' para que se vean en el mapa
|
||||||
const { paradaCercana } = useParadaCercana();
|
|
||||||
|
|
||||||
stops.forEach(stop => {
|
stops.forEach(stop => {
|
||||||
// Evitar sobre dibujar si es la cercana (useFlujoPrincipal ya se encargó)
|
// Evitar sobre dibujar si es la cercana (useFlujoPrincipal ya se encargó)
|
||||||
if (paradaCercana.value && stop.id === paradaCercana.value.id) return;
|
if (paradaCercana.value && stop.id === paradaCercana.value.id) return;
|
||||||
@ -441,6 +441,9 @@ async function updateMapMarkers() {
|
|||||||
() => handleBusStopClick(stop)
|
() => handleBusStopClick(stop)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
} finally {
|
||||||
|
isUpdatingMarkers.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMarkersStyles() {
|
function updateMarkersStyles() {
|
||||||
@ -679,8 +682,9 @@ async function calculateWalkingPath(origin: { lat: number, lng: number }, target
|
|||||||
|
|
||||||
// 2. Trazar línea de puntos verde siguiendo RED VIAL PRINCIPAL
|
// 2. Trazar línea de puntos verde siguiendo RED VIAL PRINCIPAL
|
||||||
try {
|
try {
|
||||||
const { Route } = await google.maps.importLibrary("routes") as any;
|
const { RoutesService } = await google.maps.importLibrary("routes") as any;
|
||||||
const response = await Route.computeRoutes({
|
const routeService = new RoutesService();
|
||||||
|
const response = await routeService.computeRoutes({
|
||||||
origin: {
|
origin: {
|
||||||
location: {
|
location: {
|
||||||
latLng: { latitude: origin.lat, longitude: origin.lng }
|
latLng: { latitude: origin.lat, longitude: origin.lng }
|
||||||
|
|||||||
Reference in New Issue
Block a user