fix: strictly decouple schedules selection from map visuals to keep map clean

This commit is contained in:
2026-02-28 22:23:37 -05:00
parent 23b7bd4539
commit 1dd250ca42

View File

@ -37,19 +37,15 @@ const { limpiarMapa: limpiarTodoCentralizado } = useMapState();
const showETACard = ref(false);
// Local old tracking states can be removed, but kept for compatibility or Uber flow:
const markers = ref<any[]>([]);
const promoMarkers = ref<any[]>([]);
const userMarker = ref<any>(null);
const currentMarkerMode = ref<'dot' | 'pin' | null>(null);
const isUpdatingMarkers = ref(false);
const unitMarkers = ref<Map<string, google.maps.Marker>>(new Map());
const unitFetchInterval = ref<any>(null);
const userCoords = ref<{ lat: number; lng: number } | null>(null);
const walkingPolyline = ref<google.maps.Polyline | null>(null);
const optimalStopPulse = ref<any>(null);
const showRouteDropdown = ref(false);
const routeCardRef = ref<HTMLElement | null>(null);
const mappingSequenceId = ref(0);
const wasSelectedFromMap = ref(false);
const isInternalSelection = ref(false);
@ -244,9 +240,12 @@ async function initializeMap() {
});
}
// If we have a selected route, show its stops
if (routeStore.selectedRouteId && routeStore.selectedRouteStops.length > 0) {
// If we have a selected route AND it was from map, show its stops
if (routeStore.selectedRouteId && routeStore.selectedRouteStops.length > 0 && wasSelectedFromMap.value) {
updateMapMarkers();
} else {
// If no route or not from map, ensure it's clean (promos stay though)
clearMapMarkers();
}
// Show promotions on the map
@ -277,10 +276,14 @@ watch(
}
if (routeId) {
// Route stops are automatically loaded when route is selected
// Si el ID cambió pero no estamos en el flujo de búsqueda (selectRouteAndClose),
// forzamos el skipZoom para evitar la animación de "encontrando parada".
await updateMapMarkers(true);
if (wasSelectedFromMap.value) {
// Only update map visuals if selection came from the Map search flow
await updateMapMarkers(true);
} else {
// If selection came from Schedules or elsewhere, KEEP THE MAP CLEAN
console.log('Selection from outside Map - clearing map markings');
clearMapMarkers();
}
} else {
// Clear markers when no route is selected
lastProcessedRouteId.value = null;