NavigationRouteAddObserver

public protocol NavigationRouteAddObserver : Observer

Declares an observer that can receive a route has been added to the navigation session.

A new route can be added to the session under the following circumstances:

To receive notifications of a route being added to the session, first implement an observer object that conforms to NavigationRouteAddObserver, for example:

class CustomRouteObserver: NavigationRouteAddObserver { ... }

In order to complete conformance, the observer object must implement the following callback:

func didAddRoute(route: options: reason:) {
    // add code here that handles the route being added to the session
}

This callback function could render the newly added route on the map, for example.

Next, add this observer with navigation using addRouteAddObserver(_:). To stop notifications of a route being added to the session, remove the observer using removeRouteAddObserver(_:).

Please note that NavigationRouteAddObserver is notified only when the replanned route differs from the current active route in terms of geometry. Events like route refresh and increment update of guidance instructions will not notify this observer. For these scenarios the NavigationRouteUpdateObserver is notified.

The complementary observer that notifies on the removal of routes from the session is NavigationRouteRemoveObserver.

Important

The addition of a route to the session does not necessarily make it active. To receive notifications of changes to the active route, use the NavigationActiveRouteChangeObserver.