Protocols
The following protocols are available globally.
-
Entry point for all methods related to the navigation visualization module. Instances of
NavigationVisualization
are created usingNavigationVisualizationFactory.create(map:navigation:styleConfiguration:)
. You should call methods on these instances from the main thread only, otherwise an exception can occur.A
NavigationVisualization
instance is used by first providing aRoutePlan
withdisplayRoutePlan(:_)
. After that, theTomTomSDKRoute.Route
s contained in theRoutePlan
are displayed on the map, and you can usesetActiveRoute(_:)
to select a route to be navigated on. You can access the list of route primitives displayed on the map usingroutes
. The selected route and the alternative routes are styled with the properties contained in theStyleConfiguration
provided toNavigationVisualizationFactory.create(map:navigation:styleConfiguration:)
. After selecting the type of navigation guidance withselectGuidanceType(_:)
, you can start the navigation session withTomTomSDKNavigation.Navigation.start()
. Once the navigation session is started, the route that is set becomes the active route. When you’re finished usingNavigationVisualization
, callTomTomSDKNavigation.Navigation.stop()
. You can then callclearRoutePlan()
to remove all the primitives that have been added to the map by the module. Visualization of on-route traffic incidents can be enabled or disabled usingareTrafficIncidentsEnabled
. If aTomTomSDKRoute.Route
contained in theRoutePlan
has traffic data available andareTrafficIncidentsEnabled
istrue
, traffic incidents are displayed on the map on top of thatTomTomSDKRoute.Route
. You can access the list of traffic incidents that are on a route usingtrafficIncidents(on:)
.The navigation visualization module subscribes to certain listeners during its life cycle, so that it can react automatically to important events:
TomTomSDKNavigation.NavigationStartObserver
- Notifies the module when a navigation session starts. The module reacts by removing the alternative routes from the map, setting the camera tracking mode toTomTomSDKMapsDisplay.CameraTrackingMode.follow
, and setting a default tilt angle.TomTomSDKNavigation.NavigationProgressObserver
- Notifies the module as the driver progresses on the route. The module reacts by updating the visual cue of the progress on the route (i.e., the grayed-out region behind the vehicle).TomTomSDKNavigation.NavigationRouteObserver
- Notifies the module if the driver deviates from the current route. A new route is provided along with the notification. The module reacts by replacing the current route with the new one.TomTomSDKNavigation.NavigationGuidanceObserver
- Notifies the module when new on-route instructions are available. The new instructions are provided along with the notification. The module reacts by updating the route with the new instructions.TomTomSDKNavigation.NavigationArrivalObserver
- Notifies the module when the driver reaches the destination. The module reacts by removing the route from the map, setting camera tracking mode toTomTomSDKMapsDisplay.CameraTrackingMode.follow
, and setting the default 2D view. The module reacts by, for example, showing or hiding certain traffic markers (seeRouteTrafficIncidentStyle.markerVisibilityByCategory
).
Important
This is a Public Preview API. It may be changed or removed at any time.Declaration
Swift
public protocol NavigationVisualization : AnyObject