NavigationVisualization
Entry point for all methods related to the navigation visualization add-on.
Instances of NavigationVisualization
are created using NavigationVisualizationFactory.create()
. 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 a RoutePlan
with displayRoutePlan()
. After that, the routes contained in the RoutePlan
are displayed on the map, and you can use selectRoute()
to select a route to be navigated on. You can access the list of route primitives displayed on the map using routes
. The selected route and the alternative routes are styled with the properties contained in the StyleConfiguration
provided to NavigationVisualizationFactory.create()
. After selecting the type of navigation guidance with selectGuidanceType()
, you can start the navigation session with NavigationController.start()
. Once the navigation session is started, the route that is selected becomes the active route. When you're done using NavigationVisualization
, call NavigationController.stop()
. You can then call clear()
to remove all the primitives that have been added to the map by the add-on.
Visualization of on-route traffic incidents can be enabled or disabled using setTrafficIncidentsEnabled()
. If a Route
contained in the RoutePlan
has traffic data available and areTrafficIncidentsEnabled
is true
, traffic incidents are displayed on the map on top of that Route
. You can access the list of traffic incidents that are on a route using getTrafficIncidents()
.
To support Android configuration changes properly, create a NavigationVisualization
instance on the ViewModel and use replaceMap()
once the Activity/Fragment is recreated.
The navigation visualization add-on subscribes to certain listeners during its life cycle, so that it can react automatically to important events:
OnNavigationStartedListener
- Notifies the add-on when a navigation session starts. The add-on reacts by removing the alternative routes from the map, setting the camera tracking mode toCameraTrackingMode.FOLLOW_ROUTE
, and setting a default tilt angle.OnProgressUpdateListener
- Notifies the add-on as the driver progresses on the route. The add-on reacts by updating the visual cue of the progress on the route (i.e., the grayed-out region behind the vehicle).OnRouteUpdatedListener
- Notifies the add-on if the driver deviates from the current route. A new route is provided along with the notification. The add-on reacts by replacing the current route with the new one.OnGuidanceUpdateListener
- Notifies the add-on when new on-route instructions are available. The new instructions are provided along with the notification. The add-on reacts by updating the route with the new instructions.OnDestinationReachedListener
- Notifies the add-on when the driver reaches the destination. The add-on reacts by removing the route from the map, setting camera tracking mode toCameraTrackingMode.FOLLOW
, and setting the default 2D view.OnCameraChangeListener
- Notifies the add-on when a parameter of the camera changes. The add-on 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.
Functions
Clears NavigationVisualization
.
Displays a RoutePlan
on the map.
Gets the list of traffic incidents that are being displayed on a certain Route
.
Replaces the current TomTomMap
with a new one.
Selects the type of guidance to be used when a navigation session starts.
Selects a Route
to be navigated when a navigation session starts.
Enables or disables visualization of on-route traffic incidents.