NavigationActiveRouteChangeObserver

public protocol NavigationActiveRouteChangeObserver : Observer

Declares an observer that can receive events indicating that the active route has been changed. The active route is the only followed route for which the navigation provides guidance.

The active route is changed when:

  • The navigation is started with a new route using the start(navigationOptions:) method.
  • The navigation is updated using the setActiveRoutePlan(_:) method. Note, if setActiveRoutePlan(_:) is called with the currently active RoutePlan, this observer will not receive an active route changed notification.
  • Replanning is completed by the navigation and a new route is set as the active route. Replanning can be triggered by:
    • Deviating from the active route.
    • Running out of battery, in the case of Electric Vehicle navigation.
    • Requesting a navigation language change, by using the preferredLanguage property.
    • Continuous replanning:
    • A better route proposal is found and accepted automatically.
    • A better route proposal is accepted using the selectActiveRoute(routeId:) method.
    • A better route proposal is accepted by steering into the proposed route.

In order to receive notifications for active route changes, implement an instance of NavigationActiveRouteChangeObserver and register the observer by calling addActiveRouteChangeObserver(_:). For example:

class CustomRouteObserver: NavigationActiveRouteChangeObserver {
    func didChangeActiveRoute(route:) {
        // Implement the necessary functionality for handling the active route being changed
    }
}

The NavigationActiveRouteChangeObserver is notified after adding the route to the navigation and prior to the removal of the old active route. Hence, it is notified after the NavigationRouteAddObserver and before the NavigationRouteRemoveObserver.

To stop receiving these events, remove the observer using removeActiveRouteChangeObserver(_:).