Traffic

VERSION 1.0.0
PUBLIC PREVIEW

Navigation SDK for Android is only available upon request. Contact us to get started.

This guide will provide you with instructions on how to enable or disable traffic incidents on your route, along with guidance on requesting a list of traffic incidents specific to your route. Additionally, we will elaborate on the various types of traffic incidents that are supported and may be encountered during your journey.

Project set up

  1. Before proceeding with this guide, follow the Quickstart guide for Maps and Quickstart guide for Navigation to create the TomTomMap and TomTomNavigation objects, which are essential for use with the Navigation Visualization module responsible for displaying on-route traffic incidents.
  2. Add the Navigation Visualization dependency in the build.gradle of your application module and synchronize the project:
    implementation("com.tomtom.sdk.maps.visualization:navigation:1.0.0")
  3. Use the NavigationVisualizationFactory.create method to create the NavigationVisualization object:
    navigationVisualization =
    NavigationVisualizationFactory.create(tomTomMap, tomtomNavigation)

Displaying traffic incidents on the route

To display traffic incidents on the route, call the displayRoutePlan function with a RoutePlan:

navigationVisualization.displayRoutePlan(routePlan)

By default, traffic incidents on the route are enabled. However, if you want to disable them, you can do so by using setTrafficIncidentsEnabled. To retrieve the list of displayed TrafficIncidents on a route, use getTrafficIncidents like this:

navigationVisualization.getTrafficIncidents(route)
center

Traffic incident types

We currently offer support for four types of traffic incidents on the route, which include:

Jam

Jam incidents denote regular traffic congestion, identifiable by a numeric marker that represents delays in minutes. These delays can fall into three categories:

Minor

minor

Moderate

moderate

Major

major

RoadWorks

Road works can come in four different magnitudes:

Unknown

unknown

Minor

minor

Moderate

moderate

Major

major

RoadClosed

While we typically avoid routing through closed roads, there might be situations where users deviate from the original route to a closed road. The RoadClosed incident has no associated magnitude, unlike other incident types.

road closed

Unknown

Incidents that do not fall into the categories mentioned earlier are represented under the "unknown" category. Similar to road works, they can also be categorised into four different magnitudes:

Unknown

unknown

Minor

minor

Moderate

moderate

Major

major

Traffic style customisation

During the creation of NavigationVisualization through the NavigationVisualizationFactory.create, StyleConfiguration can be passed in to define custom stylization. By default, if it’s not passed in, the default style will be used. To define a custom stylization for traffic, see RouteTrafficIncidentStyle. The custom style object can be passed as:

1navigationVisualization =
2 NavigationVisualizationFactory.create(
3 tomTomMap,
4 tomtomNavigation,
5 styleConfiguration = StyleConfiguration(routeTrafficIncident = customTrafficStyle)
6 )

Next steps

Since you have learned how to display traffic incidents on the route, here are recommendations for the next steps: