NavigationRouteAddObserver
public protocol NavigationRouteAddObserver : Observer
Informs the caller that a route has been added to the navigation session.
A new route can be added to the session under the following circumstances:
- When navigation has started with a route using the
start()method withNavigationOptionsas an argument. - When navigation is updated using the
update(navigationOptions:)method. Note, if the new route is identical, which means it has the sameRoute/idas the current active route, it will not trigger the observer. - When navigation finds a better route and the
TomTomSDKNavigationEngines/BetterProposalAcceptanceModeis set to eitherTomTomSDKNavigationEngines/BetterProposalAcceptanceMode/manualorTomTomSDKNavigationEngines/BetterProposalAcceptanceMode/unreachableOnly. - When navigation finds a reachable route and
TomTomSDKNavigationEngines/BetterProposalAcceptanceModeis set toTomTomSDKNavigationEngines/BetterProposalAcceptanceMode/manual. - When navigation finds a reachable route, due to the navigated route being unreachable, and
TomTomSDKNavigationEngines/BetterProposalAcceptanceModeis set toTomTomSDKNavigationEngines/BetterProposalAcceptanceMode/unreachableOnlyso that the reachable route is automatically applied. - When the
TomTomSDKNavigationEngines/BetterProposalAcceptanceModeis set toTomTomSDKNavigationEngines/BetterProposalAcceptanceMode/automaticand the proposed route is automatically applied. - When navigation automatically replans and adds the newly planned route to the session.
- When the
preferredLanguageis set and the replanning with the new language has completed.
To receive notifications of a route being added to the session, first implement an observer object that conforms to NavigationRouteAddObserver, for example:
class RouteObserver: 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, register this observer with navigation using addRouteAddObserver(_:).
To stop notifications of a route being added to the session, unregister the observer using removeRouteAddObserver(_:).
Please note that NavigationRouteAddObserver is triggered 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 trigger this observer.
For these scenarios the NavigationRouteUpdateObserver is called.
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.
Important
This is a Public Preview API. It may be changed or removed at any time.
-
Called when a
Routehas been added to the navigation session.Declaration
Swift
func didAddRoute(route: Route, options: RoutePlanningOptions, reason: RouteAddedReason)Parameters
routeThe
Routethat has been added to the navigation session.optionsThe
RoutePlanningOptionsthat has been used forRoute.reasonThe reason for adding the
Route.
TomTom SDK for iOS (0.40.0)
NavigationRouteAddObserver