Members
# constant ARROW_GLYPHS
The five built-in direction-arrow glyphs for the route stamp, authored pointing RIGHT (+x = travel).
Mapbox draws them to canvas via Path2D; Google rotates them a quarter-turn (toUpwardPath)
since its line symbols face -y. filled glyphs use fill; the rest stroke at ARROW_STROKE_UNITS.
# constant ARROW_SYMBOL_SCALE
Google Symbol.scale at stamp scale 1. Set to 1.2 so Google matches Mapbox and the CMS preview,
which both render the glyph at 1.2 px/unit. Calibration knob — nudge if Google reads too large/small.
# constant COMET_FRACTION
Length of the comet streak as a fraction of the route, matching the CMS comet dash (~12/100).
# constant DEFAULT_STAMP_SPACING_PX
Distance in px between repeated stamps when the stamp supplies no spacingPx.
# constant GRAPHIC_LABEL_HOVER_TEXT_SIZE_INCREASE
Matches the graphic-label hover bump in getGraphicLabelStyle.
# constant ICON_BASE_PX
Base rendered size (device-independent px) for directions-renderer icons: rendered size = ICON_BASE_PX × scale.
# constant LOADING_PHASES
Phases of the initial map-content load. Later updates (pan, zoom, floor change) do not emit progress.
# constant MI_FEATURE_STATE_PROBE
Unused feature-state key. Symbol layers on MI_GEOJSON_SOURCE that do not otherwise read feature-state must still mention one.
Mapbox GL JS >= 3.21 throws Cannot read properties of undefined (reading 'paint')
from SymbolBucket.update when setFeatureState has run on a source and another symbol
layer on that source has no feature-state paint, then a paint or image update lands
in the same frame. Rapid location clicks do both: hover/selection writes feature-state,
and the following view update adds icons. The probe is never written, so icon opacity
stays 1. https://github.com/mapbox/mapbox-gl-js/issues/13714
Methods
# cometWindow(distanceTraveled, length, fractionopt) → {Object|null}
Start/end distances (in meters) of the comet streak window for a given travelled distance. The
streak is a fixed fraction of the route length; the head restarts at the route start when it passes
the end (the tail clamps at the seam, so the streak re-grows from the start rather than wrapping).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
distanceTraveled |
number
|
Distance travelled so far, in meters. |
||
length |
number
|
Total route length, in meters. |
||
fraction |
number
|
<optional> |
COMET_FRACTION | Streak length as a fraction of |
Window, or null when the route has no length.
Object
|
null
# deriveHoverGating(hoverRuleopt) → {Object}
Derives which hover effects the Mapbox v3 view should apply from the solution's hover state DisplayRule. Absent config falls back to the default hovered state, so hover stays on unless a solution explicitly neutralizes the rule.
Fill darken (polygon and extrusion share one flag) and icon scale are on/off — the Mapbox paint intensity is fixed; badge scale uses the rule's actual value.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
hoverRule |
DisplayRule
|
<optional> |
|
Object
# enlargedGraphicLabel()
A copy of a graphic label with the hover text-size bump. text-size is a layout property, so feature-state cannot change it on the source feature. The original feature is left unchanged.
# getGlyph()
Resolve an unvalidated arrowStyle to a glyph, falling back to DEFAULT_ARROW_STYLE for an
unknown or absent key. Takes string, not ArrowStyle, because renderers get this value
straight from caller/CMS options where it has never been narrowed.
The own-property check diverges from main, which indexed the object directly and fell back with ||:
that reached inherited members, so arrowStyle: 'toString' yielded a function instead of the default.
# getGoogleMap()
Narrows the interface-level provider-map union to the Google map this renderer runs on (it is only ever constructed via the Google view's DirectionsRenderer getter); instanceof checks that invariant instead of asserting it. Null when no map is available yet.
# getIconZoomRange()
Get union zoom range for icon+badge (icon view model shows when either is in range).
# getMapboxMap()
Narrows the interface-level provider-map union to the Mapbox map this renderer runs on (it is only ever constructed via a Mapbox view's DirectionsRenderer getter); instanceof checks that invariant instead of asserting it. Null when no map is available yet.
# hasContextSwitch(leg) → {boolean}
Checks if the given leg represents a context switch.
Parameters:
| Name | Type | Description |
|---|---|---|
leg |
Leg
|
The route leg to check for context switch. |
Returns true if the leg is a context switch, false otherwise.
boolean
# hideProviderLogo(element, providerSelector)
Hides the map provider's branding (logo and attribution control) by injecting a single, idempotent