# new DirectionsRenderer(options)
Creates an instance of DirectionsRenderer.
The solution's CMS styling (solutionConfig.directionsRendererConfig) is read once, here at
construction. Create the renderer after the MapsIndoors instance has fired its ready event —
a renderer constructed earlier silently keeps the built-in defaults.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
options |
mapsindoors.directions.DirectionsRendererOptions
|
|||
mapsIndoors |
mapsindoors.MapsIndoors
|
MapsIndoors instance. |
||
fitBounds |
boolean
|
<optional> |
true | When fitBounds is set to true, the map's viewport will be fitted to the bounds of the rendered route. |
fitBoundsPadding |
number
|
Padding
|
<optional> |
Adds a padding to the viewport when it is fitted to the to the bounds of the rendered route. |
|
animation |
object
|
<optional> |
DefaultRouteAnimation | Animation class for animating the route. This can be diabled by setting the animation to |
strokeColor |
string
|
<optional> |
Sets the color that the route will be displayed with. The color property is specified a css color value. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value |
|
strokeOpacity |
number
|
<optional> |
Sets the opacity of the route. The opacity property is specified as a value between 0 and 1. See https://developer.mozilla.org/en-US/docs/Web/CSS/opacity |
|
strokeWeight |
number
|
<optional> |
Sets the weight of the route in pixels. |
|
strokeStyle |
string
|
<optional> |
'solid' | Sets the route line style: 'solid', 'dashed' or 'dotted'. |
halo |
object
|
<optional> |
Halo/casing drawn beneath the route ({ enabled, color, weight, opacity }). Partial objects merge with the CMS/default values. |
|
stamp |
object
|
<optional> |
Repeated marker along the route ({ preset, iconUrl, spacingPx, scale }); a present iconUrl wins over preset. Partial objects merge. |
|
legBoundaryIcons |
object
|
<optional> |
Icon URL per connector type (+ shared scale), applied at the next setRoute. Partial objects merge. |
|
startDisplayRule |
object
|
<optional> |
Display rule for the route start marker (icon, label, zoom range, labelStyle); icon and label apply at the next setRoute, the zoom range applies immediately. Partial objects merge. |
|
endDisplayRule |
object
|
<optional> |
Display rule for the route end marker, same application timing as startDisplayRule. Partial objects merge. |
|
elevation |
object
|
<optional> |
3D line elevation ({ elevated, heightMeters }); Mapbox GL v3 only. Partial objects merge. |
|
fitBoundsMaxZoom |
number
|
<optional> |
Caps the zoom when the viewport fits to the route. |
|
visible |
boolean
|
<optional> |
true | Sets the initial visibility of the route. |
defaultRouteStopIconProvider |
RouteStopIconProvider
|
<optional> |
The default icon provider for route stop icons. |
Example
const directionsRenderer = new mapsindoors.directions.DirectionsRenderer(...);
Methods
# ()
Restores every POI icon this renderer hid behind a route marker: locations that had their own display rule get that exact rule back, the rest get their (empty) slot cleared. Both writes are batched — one redraw each — instead of one per location.
# (locationIds)
Hides the given POIs' icons in one batched display-rule write. The hide is merged into the app's
own rule (captured first, for restore) so only iconVisible changes. Icon-only on purpose —
visible: false would also drop the location's polygon and 3D walls.
Parameters:
# ()
Hides the origin/destination POI's icon while a configured start/end marker renders in its place.
# completeDirectionsUsageTracking(optionsopt) → {void}
Logs a directions_completed event for the currently active route. Call this when the user explicitly finishes navigation.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
Object
|
<optional> |
|
usage_percentage |
number
|
<optional> |
Completion percentage from 0 to 100, where 100 means the route was fully completed. Defaults to tracked progress when omitted. |
void
# destroy()
Releases everything the renderer holds: map layers, sources, images, event listeners, the running animation and every hidden POI icon. The renderer must not be used afterwards. Does not log a directions-completed event — call DirectionsRenderer#completeDirectionsUsageTracking first.
# getStepIndex()
Returns the index of the step currently being displayed on the map. It returns -1 if no step is selected.
# setAnimation(animation)
Sets the animation for the route.
Parameters:
| Name | Type | Description |
|---|---|---|
animation |
object
|
# setLegIndex(index)
Sets the index which leg of the route to display on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number
|
# setOptions(options)
Sets the DirectionsRendererOptions used for rendering the route. Nested blocks (see
BLOCK_OPTION_KEYS) merge field-by-field into their current value; animation is routed through
setAnimation (clear-then-set). Line styling, stamp, halo and elevation update live.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
DirectionsRendererOptions
|
# async setRoute(route, stopConfigsopt)
Sets the DirectiyonsResult to be rendered on the map.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
route |
DirectionsResult
|
||
stopConfigs |
Map:.<number:, RouteStopConfig:>
|
<optional> |
A map of RouteStopConfig objects. The key is the index of the stop in the route. |
# setStepIndex(stepIndex, legIndexopt)
Sets the index which leg of the route to display on the map.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
stepIndex |
number
|
||
legIndex |
number
|
<optional> |
# setVisible(visible)
Sets the visibility of the route on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
visible |
boolean
|