fix(map): ensure persistence of routes between views and thorough cleanup on 'X' click
This commit is contained in:
@ -98,16 +98,20 @@ function closeUberSearch() {
|
||||
|
||||
async function animateAndReload() {
|
||||
isBannerClosing.value = true;
|
||||
|
||||
// 1. Limpiar estado de datos (Pinia)
|
||||
routeStore.clearSelection();
|
||||
router.replace({ query: {} });
|
||||
|
||||
// Limpiar mapa sin recargar
|
||||
// 2. Limpiar visuales del mapa (Markers, Polylines, Unidades)
|
||||
clearMapMarkers();
|
||||
limpiarCaminata();
|
||||
|
||||
// 3. Resetear fases de UI
|
||||
showETACard.value = false;
|
||||
routePhase.value = 'idle';
|
||||
|
||||
// Recentrar en el usuario si está disponible (soft-reset)
|
||||
// 4. Recentrar en el usuario si está disponible (soft-reset)
|
||||
if (userCoords.value) {
|
||||
setCenter(userCoords.value.lat, userCoords.value.lng);
|
||||
setZoom(16);
|
||||
@ -165,9 +169,7 @@ onMounted(async () => {
|
||||
onUnmounted(() => {
|
||||
if (unitFetchInterval.value) clearInterval(unitFetchInterval.value);
|
||||
if (carouselTimer.value) clearInterval(carouselTimer.value);
|
||||
clearMapMarkers();
|
||||
unitMarkers.value.forEach(m => m.setMap(null));
|
||||
unitMarkers.value.clear();
|
||||
// NOTA: No llamamos a clearMapMarkers() para mantener la ruta si el usuario vuelve
|
||||
});
|
||||
|
||||
async function initializeMap() {
|
||||
@ -191,12 +193,6 @@ async function initializeMap() {
|
||||
});
|
||||
}
|
||||
|
||||
if (routeStore.selectedRouteId && routeStore.selectedRouteStops.length > 0 && routeStore.wasSelectedFromMap) {
|
||||
updateMapMarkers();
|
||||
} else {
|
||||
clearMapMarkers();
|
||||
}
|
||||
|
||||
updatePromoMarkers();
|
||||
|
||||
if (authStore.userProfile?.auto_location) {
|
||||
@ -204,13 +200,26 @@ async function initializeMap() {
|
||||
}
|
||||
|
||||
if (routeStore.selectedRouteId && routeStore.wasSelectedFromMap) {
|
||||
highlightOptimalStopForRoute();
|
||||
if (routeStore.selectedRouteStops.length === 0) {
|
||||
await routeStore.loadRouteStops(routeStore.selectedRouteId);
|
||||
}
|
||||
updateMapMarkers();
|
||||
routePhase.value = 'navigating'; // Restaurar en modo navegación al volver
|
||||
} else {
|
||||
clearMapMarkers();
|
||||
}
|
||||
}
|
||||
|
||||
// MARKER RECYCLING & REACTIVITY OPTIMIZATION
|
||||
function clearMapMarkers() {
|
||||
limpiarTodoCentralizado()
|
||||
limpiarTodoCentralizado();
|
||||
|
||||
// Limpiar también los marcadores de las unidades (buses)
|
||||
if (unitMarkers.value.size > 0) {
|
||||
unitMarkers.value.forEach(m => m.setMap(null));
|
||||
unitMarkers.value.clear();
|
||||
}
|
||||
|
||||
if (userCoords.value) {
|
||||
reDrawUserMarker();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user