replanRoute

fun replanRoute(resultCallback: ReplanRoutesCallback? = null)

Triggers route recalculation for the case when user wants to change route options during active guidance.

Route recalculation is an asynchronous operation. You can track reroute progress via RerouteStateObserver, use RerouteController.registerRerouteStateObserver to set one. In case of successful route replan, you will receive new routes in RoutesObserver with RoutesUpdatedResult.reason equals to RoutesExtra.ROUTES_UPDATE_REASON_REROUTE.

Alternatively, you can pass a ReplanRoutesCallback parameter to receive the result of the rerouting for once. Keep in mind that the callback will be called on the main thread.

Route options are supposed to be updated by RerouteOptionsAdapter. Implement your RerouteOptionsAdapter so that it updates all route options which users can modify during active guidance. Set your RerouteOptionsAdapter to MapboxNavigation using setRerouteOptionsAdapter.

Be aware that route replan could be interrupted by a new reroute, for example the one caused by deviation from the primary route. Because of that, it's important to update all changeable route options on every reroute in RerouteOptionsAdapter and be ready to receive RerouteState.Interrupted in RerouteStateObserver.

This method does nothing if rerouting is disabled. See isRerouteEnabled to check if rerouting is enabled and setRerouteEnabled to turn off/on rerouting.

Parameters

resultCallback

optional ReplanRoutesCallback to receive the result of the rerouting.