onRouteAlternativeRequestFinished

abstract fun onRouteAlternativeRequestFinished(    routeProgress: RouteProgress,     alternatives: List<NavigationRoute>,     routerOrigin: RouterOrigin)

Invoked when on-demand alternative routes request finishes.

The alternatives list always represent all available, up-to-date, alternatives for the current route.

The alternatives are not automatically added to MapboxNavigation, you need to add them manually to trigger RoutesObserver, for example:

mapboxNavigation.requestAlternativeRoutes(
NavigationRouteAlternativesRequestListener { routeProgress, alternatives, routerOrigin ->
val newRoutes = mutableListOf<NavigationRoute>().apply {
add(mapboxNavigation.getNavigationRoutes().first())
addAll(alternatives)
}
mapboxNavigation.setRoutes(newRoutes)
}
)

You can filter the alternatives out before setting them back to MapboxNavigation based on requirements.

Parameters

routeProgress

the current route's progress.

alternatives

list of alternative routes, can be empty.

routerOrigin

reports the source of all the new alternative routes in the list. If there are no new routes, reports the source that returned the latest additions.