Customizing the Route Animation
The DirectionsRenderer
includes functionality to display an animated line that traces the route's path when displayed. You have control over the visual style and timing of this animation.
Accessing the Route Animation Controller
To customize the animation, you first need to access the dedicated animation controller object from your DirectionsRenderer
instance. Use the getAnimation()
method for this:
JavaScript
Setting Animation Options
The routeAnimation
object has a setOptions()
method that allows you to configure the animation's properties. Pass an object to this method where the keys match the options you want to modify.
These options are defined by the mapsindoors.directions.RouteAnimationOptions
interface:
Interface: mapsindoors.directions.RouteAnimationOptions
speed
number
300
The speed of the animation in meters per second (m/s).
minAnimationTime
number
1.2
The minimum duration in seconds for the animation. Ensures very short routes still have a perceivable animation effect.
strokeColor
string
'hsl(215, 67%, 96%)'
strokeOpacity
number
1
strokeWeight
number
2
The thickness (weight) of the animated line in pixels.
Example
This example shows how to create a DirectionsRenderer
and immediately configure its animation to be a thicker, red line with a slightly faster speed.
JavaScript
By calling setOptions()
on the object returned by getAnimation()
(here stored in routeAnimation
), you can tailor the route reveal animation to better match your application's design or desired user experience. These settings will be applied the next time a route is rendered using setRoute()
.
Last updated
Was this helpful?