diff --git a/frontend/src/views/MapView.vue b/frontend/src/views/MapView.vue index 403b4c6..db15e9a 100644 --- a/frontend/src/views/MapView.vue +++ b/frontend/src/views/MapView.vue @@ -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([]); const promoMarkers = ref([]); const userMarker = ref(null); -const currentMarkerMode = ref<'dot' | 'pin' | null>(null); const isUpdatingMarkers = ref(false); const unitMarkers = ref>(new Map()); const unitFetchInterval = ref(null); const userCoords = ref<{ lat: number; lng: number } | null>(null); -const walkingPolyline = ref(null); const optimalStopPulse = ref(null); const showRouteDropdown = ref(false); const routeCardRef = ref(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;