NavigationRouteRemoveObserver
public protocol NavigationRouteRemoveObserver : Observer
Declares an observer that can receive the active or proposed route has been removed from the navigation session.
The active route is removed from the session when:
- The navigation has completed replanning and set the new replanned route as the active one.
- The navigation is updated using the
setActiveRoutePlan(_:)
. - A better route proposal has been accepted using the
selectActiveRoute(routeId:)
method. Note, if thesetActiveRoutePlan(_:)
is called with the same route as the current active one, this observer will not be notified. - The user is not following the active route as reported by
NavigationRouteTrackingStateUpdateObserver
.
The proposed route is removed from the session when:
- The user is not following the route, as reported by
NavigationRouteTrackingStateUpdateObserver
resulting in the proposed route being placed in theTomTomSDKNavigationEngines/RouteTrackingState/unfollowedRoutes
list. - The navigation has finished planning a new route due to replanning initiated by the navigation.
- The navigation is updated using the
setActiveRoutePlan(_:)
method. Note, if thesetActiveRoutePlan(_:)
is called with the same route as the proposed one, this observer will not be notified.
To receive notifications of a route being removed from the session, first implement an observer object that conforms to NavigationRouteRemoveObserver
, for example:
class CustomRouteObserver: NavigationRouteRemoveObserver { ... }
/// In order to complete conformance, the observer object must implement the following callback:
func didRemoveRoute(route: reason:) {
// add code here that handles the route being removed from the session
}
This callback function could remove a rendered route from the map, for example.
Next, add this observer with navigation using addRouteRemoveObserver(_:)
.
To stop notifications of a route being removed from the session, remove the observer using removeRouteRemoveObserver(_:)
.
The complementary observer that provides updates on the addition of routes to the session is NavigationRouteAddObserver
.
Note, during navigation in turn by turn mode there will always be one active route.
Therefore, any removal of the current active route will always be preceded by an NavigationActiveRouteChangeObserver
call, with details of the new active route.
-
Notifies when a
Route
has been removed from the navigation session.Declaration
Swift
func didRemoveRoute(route: Route, reason: RouteRemovedReason)
Parameters
route
The
Route
that has been removed from the navigation session.reason
The reason for removing the route.