@@ -3,8 +3,15 @@ import { Fragment, useCallback, useRef } from 'react'
33import { Marker , Polyline , Popup } from 'react-leaflet'
44import { useAgencyList } from 'src/hooks/useAgencyList'
55import { busIcon , busIconPath } from '../../utils/BusIcon'
6- import type { PositionGroup } from '../map-types'
7- import { actualRouteStopMarker } from '../MapContent'
6+ import type { Point , PositionGroup } from '../map-types'
7+ import { rideEndMarker , vehicleBearingMarker , vehicleStandingMarker } from '../mapMarkers'
8+ import {
9+ bearingZIndex ,
10+ BOOKEND_Z_INDEX ,
11+ isStanding ,
12+ speedBand ,
13+ STANDING_Z_INDEX ,
14+ } from '../vehicleBearingGlyph'
815import { BusToolTip } from './BusToolTip'
916import BusToolTipFooter from './BusToolTipFooter'
1017
@@ -14,6 +21,18 @@ interface MapRouteLayerProps {
1421 navigateMarkers : ( groupIndex : number , id : number , marker : Layer ) => void
1522}
1623
24+ /** `Point.color` holds the ping's velocity, not a colour — see `toPoint`. */
25+ function pingMarker ( { bearing, color : velocity } : Point ) {
26+ // Only the standing badge can say "heading unknown" (it drops its needle); a moving ping has
27+ // to point somewhere, and `toPoint` has already defaulted a missing SIRI bearing to 0 anyway.
28+ return isStanding ( velocity )
29+ ? { icon : vehicleStandingMarker ( bearing ) , zIndexOffset : STANDING_Z_INDEX }
30+ : {
31+ icon : vehicleBearingMarker ( bearing ?? 0 , velocity ) ,
32+ zIndexOffset : bearingZIndex ( speedBand ( velocity ) ) ,
33+ }
34+ }
35+
1736export function MapRouteLayer ( {
1837 positionGroups,
1938 showNavigationButtons,
@@ -42,22 +61,29 @@ export function MapRouteLayer({
4261 />
4362 { group . positions . map ( ( pos , i ) => {
4463 const markerKey = `${ groupIndex } -${ i } `
45- const icon =
64+ // A one-ping ride keeps the operator's logo — it never got to finish.
65+ const { icon, zIndexOffset } =
4666 i === 0
47- ? busIcon ( {
48- // eslint-disable-next-line i18next/no-literal-string -- icon lookup key, not user text
49- operator_id : pos . operator ?. toString ( ) || 'default' ,
50- name : agencyList . find ( ( agency ) => agency . operatorRef === pos . operator )
51- ?. agencyName ,
52- } )
53- : actualRouteStopMarker
67+ ? {
68+ icon : busIcon ( {
69+ // eslint-disable-next-line i18next/no-literal-string -- icon lookup key, not user text
70+ operator_id : pos . operator ?. toString ( ) || 'default' ,
71+ name : agencyList . find ( ( agency ) => agency . operatorRef === pos . operator )
72+ ?. agencyName ,
73+ } ) ,
74+ zIndexOffset : BOOKEND_Z_INDEX ,
75+ }
76+ : i === group . positions . length - 1
77+ ? { icon : rideEndMarker , zIndexOffset : BOOKEND_Z_INDEX }
78+ : pingMarker ( pos )
5479 return (
5580 < Marker
5681 ref = { ( ref ) => {
5782 markerRef . current [ markerKey ] = ref
5883 } }
5984 position = { pos . loc }
6085 icon = { icon }
86+ zIndexOffset = { zIndexOffset }
6187 key = { markerKey } >
6288 < Popup minWidth = { 300 } maxWidth = { 700 } >
6389 < BusToolTip position = { pos } icon = { busIconPath ( pos . operator ! ) } >
0 commit comments