setRoutes

fun setRoutes(routes: List<DirectionsRoute>, initialLegIndex: Int = 0)

Set a list of routes.

If the list is not empty, the route at index 0 is valid, and the trip session is started, then the SDK enters an Active Guidance state and RouteProgress updates will be available.

If the list is empty, the SDK will exit the Active Guidance state.

Use RoutesObserver and MapboxNavigation.registerRoutesObserver to observe whenever the routes list reference managed by the SDK changes, regardless of a source.

This call is asynchronous, only once processing finishes the effects are available through MapboxNavigation.getNavigationRoutes and RoutesObserver. If this call fails, no changes are made to the routes managed by the MapboxNavigation, they are not cleared. Observe the processing with MapboxNavigation.setNavigationRoutes's callback.

Deprecated: use #setNavigationRoutes(List) instead. To fetch NavigationRoute list use #requestRoutes(RouteOptions, NavigationRouterCallback) or create an instance of NavigationRoute via NavigationRoute.create, which requires an original DirectionsResponse object or a raw JSON response.

See also

Parameters

routes

a list of DirectionsRoutes

initialLegIndex

starting leg to follow. By default the first leg is used.