diff --git a/client/src/components/Map/MapViewGL.tsx b/client/src/components/Map/MapViewGL.tsx index 9be41e17..0287026e 100644 --- a/client/src/components/Map/MapViewGL.tsx +++ b/client/src/components/Map/MapViewGL.tsx @@ -132,6 +132,7 @@ export function MapViewGL({ places = [], dayPlaces = [], route = null, + routeSegments = [], selectedPlaceId = null, onMarkerClick, onMapClick, @@ -162,6 +163,7 @@ export function MapViewGL({ const markersRef = useRef>(new Map()) const locationMarkerRef = useRef(null) const reservationOverlayRef = useRef(null) + const routeLabelMarkersRef = useRef([]) // Refs so the reservation overlay always sees the latest callback / // options without forcing a full overlay rebuild on every prop change. const onReservationClickRef = useRef(onReservationClick) @@ -442,6 +444,35 @@ export function MapViewGL({ src.setData({ type: 'FeatureCollection', features }) }, [route]) + // Travel-time pills between consecutive places. The GL map accepted the + // routeSegments prop but never drew anything, so the labels that Leaflet + // shows were missing here (#850). Render them as HTML markers, matching the + // Leaflet pill styling. + useEffect(() => { + const map = mapRef.current + if (!map || !mapReady) return + routeLabelMarkersRef.current.forEach(m => m.remove()) + routeLabelMarkersRef.current = [] + for (const seg of routeSegments) { + if (!seg.mid || (!seg.walkingText && !seg.drivingText)) continue + const el = document.createElement('div') + el.style.pointerEvents = 'none' + el.innerHTML = `
+ ${seg.walkingText ?? ''} + | + ${seg.drivingText ?? ''} +
` + const m = new mapboxgl.Marker({ element: el, anchor: 'center' }) + .setLngLat([seg.mid[1], seg.mid[0]]) + .addTo(map) + routeLabelMarkersRef.current.push(m) + } + return () => { + routeLabelMarkersRef.current.forEach(m => m.remove()) + routeLabelMarkersRef.current = [] + } + }, [routeSegments, mapReady]) + // Update GPX geometries useEffect(() => { const map = mapRef.current