NavigationVisualization
public protocol NavigationVisualization : AnyObject
Entry point for all methods related to the navigation visualization.
To start using the navigation visualization, create an instance using
NavigationVisualizationFactory.create(map:navigation:styleConfiguration:).
Then provide the instance with a collection of TomTomSDKRoute.Route
using the NavigationVisualization.displayRoutePlan(_:) method.
After that, the TomTomSDKRoute.Route contained in the collection is displayed on the map,
and you can use NavigationVisualization.setActiveRoute(_:) to select a route on which to navigate.
You can access the collection of route primitives displayed on the map using routes property.
The active route and the alternative routes are styled with the properties contained in the StyleConfiguration
provided to NavigationVisualizationFactory.create(map:navigation:styleConfiguration:).
Next, select the type of navigation guidance with NavigationVisualization.selectGuidanceType(_:),
and start the navigation session with Navigation.start().
Once the navigation session is started, the route that is selected becomes the active route.
When you’re done using a NavigationVisualization instance, call Navigation.stop().
Then call NavigationVisualization.clear() to remove all the primitives that have been added to the map by the add-on.
If a TomTomSDKRoute.Route has traffic data available, traffic incidents are displayed on the map on top of the TomTomSDKRoute.Route.
You can access the list of traffic incident lines that are on a route using NavigationVisualization.trafficOnRoutes(_:)
property by UUID of corresponding TomTomSDKMapDisplay.Route.
The navigation visualization add-on observes certain events during its lifecycle so that it can react automatically to important events:
NavigationArrivalObserver.didStart(with:): The add-on observes when a navigation session starts.NavigationRouteObserver.didReplanRoute(replannedRoute:reason:): The add-on observes when the current route is updated.NavigationProgressObserver.didUpdateProgress(progress:): The add-on observes when progress is updated on the current route.NavigationArrivalObserver.didArriveAtDestinationOn(route:): The add-on observes when the driver reaches the destination.
Important
This is a Public Preview API. It may be changed or removed at any time.
-
The list of routes displayed on the map contains the: - active route - alternative routes.
The active route is available after calling the
setActiveRoute(_:)method. When a navigation session starts, the alternative routes are removed from this list. The list contains only the active route (activeRoute). After callingclear(), the list is empty.Declaration
Swift
var routes: [TomTomSDKMapDisplay.Route] { get } -
The
TomTomSDKMapDisplay.Routeselected for navigation. This property contains the active route during a navigation session. This is nil (empty) before routes have been displayed withdisplayRoutePlan(_:), or after callingclear().Declaration
Swift
var activeRoute: TomTomSDKMapDisplay.Route? { get } -
Enables or disables automatic zoom to routes when
displayRoutePlan(_:)is invoked.The default is
true.Declaration
Swift
var zoomToRoutesEnabled: Bool { get set } -
Displays a
RoutePlanon the map. Adds aRouteinstance to the map for eachRoutePlancontained in the route plan. By default, the first route of the plan is active, but you can set a different route usingsetActiveRoute(_:)Consecutive calls of this method replace the previousRoutePlanbeing displayed. If the providedRoutePlancontains an empty collection of routes, then this method does nothing.Declaration
Swift
func displayRoutePlan(_ routePlan: TomTomSDKRoutingVisualization.RoutePlan) -
Set an active
TomTomSDKMapDisplay.Routeto be navigated, when a navigation session starts.If the provided
TomTomSDKMapDisplay.Routeis not a route displayed withdisplayRoutePlan(_:), then this method does nothing.Declaration
Swift
func setActiveRoute(_ route: TomTomSDKMapDisplay.Route)Parameters
routeRoute to be highlighted.
-
Retrieves the collection of traffic incidents.
Declaration
Swift
func trafficOnRoute(route: TomTomSDKMapDisplay.Route) -> [TrafficIncident] -
Removes all routes that have been added with
displayRoutePlan(_:)from the map, and setsactiveRouteto nil.Declaration
Swift
func clear() -
The type of navigation guidance selected.
The default is
GuidanceType.regular. You can callselectGuidanceType(:_)to select a different navigation guidance type.Declaration
Swift
var guidanceType: GuidanceType { get } -
Selects the type of guidance to be used when a navigation session starts.
When the type
GuidanceType.regularis selected, the add-on presents regular navigation guidance. When the typeGuidanceType.laneLevelis selected, the add-on is instructed to present lane-level guidance, but it may still present regular navigation guidance. This happens because of an internal fallback mechanism that switches from lane-level guidance mode to the regular one when no lane-level data is available. The add-on switches back to lane-level guidance mode as soon as lane-level data is available again. Note that the propertyguidanceTypeis not affected when this fallback mechanism kicks in.Important
DO NOT USE
GuidanceType.lanelevel. THIS FEATURE IS NOT IMPLEMENTED YET.Declaration
Swift
func selectGuidanceType(_ guidanceType: GuidanceType)Parameters
guidanceTypeThe
GuidanceTypeto be used during the navigation session. -
Toggle the visibility of traffic incidents on route.
The default is
true.Declaration
Swift
var trafficIncidentsEnabled: Bool { get set } -
Object to address visualization of vehicle-horizon such as configuration, user interaction, etc.
Declaration
Swift
var horizonVisualization: HorizonVisualization { get }
NavigationVisualization Protocol Reference