fun setRoutesPreview(routes: List<NavigationRoute>, primaryRouteIndex: Int = 0)

Sets routes to preview. Triggers an update in RoutesPreviewObserver and changes MapboxNavigation.getRoutesPreview. Preview state is updated asynchronously as it requires the SDK to process routes and compute alternative metadata. Subscribe for updates using MapboxNavigation.registerRoutesPreviewObserver to receive new routes preview state when the processing will be completed.

If routes isn't empty, the route with primaryRouteIndex is considered as primary, the others as alternatives. To cleanup routes preview state pass an empty list as routes.

Use RoutesPreview.routesList to start Active Guidance after route's preview:

mapboxNavigation.getRoutesPreview()?.routesList?.let{ routesList ->

Routes preview state is controlled by the SDK's user. If you want to stop routes preview when you start active guidance, do it manually:




to preview


index of primary route from routes