MPDirectionsRendererOptions

data class MPDirectionsRendererOptions @JvmOverloads constructor(@ColorInt val strokeColor: Int = DEFAULT_STROKE_COLOR, @FloatRange(from = 0.0, to = 1.0) val strokeOpacity: Float = 1.0f, val strokeWeight: Float = 4.0f, val strokeStyle: MPStrokeStyle = MPStrokeStyle.SOLID, val animationSpeed: Double = 300.0, val animationMinDuration: Double = 1.2, val animationRepeating: Boolean = true, @ColorInt val animatedOverlayColor: Int? = null, @FloatRange(from = 0.0, to = 1.0) val animatedOverlayOpacity: Float = 1.0f, val animatedOverlayWeight: Float = 2.0f, val fitBoundsMaxZoom: Double? = null, val forceAnimation: Boolean = false)

An immutable set of style and behaviour options for a route rendered by MPDirectionsRenderer.

This mirrors the Web SDK DirectionsRendererOptions pattern and aligns with the iOS equivalent, encapsulating all polyline styling and animation behaviour in a single value object. Apply a set of options with MPDirectionsRenderer.setOptions; when a route is already displayed the options are applied immediately, re-styling it in place.

Every property is optional and has a sensible default, so you only need to specify what you want to change. From Kotlin, use named arguments:

val options = MPDirectionsRendererOptions(
strokeColor = Color.RED,
strokeWeight = 6f,
)
renderer.setOptions(options)

From Java, the generated overloaded constructors let you supply a leading subset of the same parameters, or use new MPDirectionsRendererOptions() for the defaults.

Constructors

Link copied to clipboard
constructor(@ColorInt strokeColor: Int = DEFAULT_STROKE_COLOR, @FloatRange(from = 0.0, to = 1.0) strokeOpacity: Float = 1.0f, strokeWeight: Float = 4.0f, strokeStyle: MPStrokeStyle = MPStrokeStyle.SOLID, animationSpeed: Double = 300.0, animationMinDuration: Double = 1.2, animationRepeating: Boolean = true, @ColorInt animatedOverlayColor: Int? = null, @FloatRange(from = 0.0, to = 1.0) animatedOverlayOpacity: Float = 1.0f, animatedOverlayWeight: Float = 2.0f, fitBoundsMaxZoom: Double? = null, forceAnimation: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Optional independent ARGB color for the animated overlay drawn on top of the route line. null (the default) reuses strokeColor.

Link copied to clipboard

Opacity of the animated overlay, in the range 0.0–1.0. Defaults to 1.0.

Link copied to clipboard

Width of the animated overlay, in pixels. Defaults to 2.

Link copied to clipboard

Lower bound for the animation duration, in seconds, applied when a route is short enough that animationSpeed alone would otherwise produce a very brief animation. Defaults to 1.2.

Link copied to clipboard

Whether the route animation repeats. Defaults to true.

Link copied to clipboard
val animationSpeed: Double = 300.0

Speed of the route animation, in meters per second. Together with animationMinDuration this determines the animation duration for a given route length. Defaults to 300.

Link copied to clipboard

Optional upper bound for the zoom level used when fitting the camera to the route. null (the default) leaves the zoom uncapped.

Link copied to clipboard
val forceAnimation: Boolean = false

Force the route animation to play even when the system "reduce motion" accessibility setting is enabled. Defaults to false.

Link copied to clipboard

ARGB color of the route line. Replaces the foreground argument of the deprecated MPDirectionsRenderer.setPolylineColors. Defaults to the MapsIndoors directions blue (DEFAULT_STROKE_COLOR).

Link copied to clipboard
val strokeOpacity: Float = 1.0f

Opacity of the route line, in the range 0.0–1.0. Exposed as a standalone value rather than being baked into the alpha channel of strokeColor. Defaults to 1.0.

Link copied to clipboard
Link copied to clipboard
val strokeWeight: Float = 4.0f

Width of the route line, in pixels. Defaults to 4.