Traffic

VERSION 1.15.0

The TomTom Map Display module provides real-time traffic updates. You can show this on the map by adding a layer with traffic flow and a layer with traffic incidents. To show or hide these layers call the following methods on the TomTomMap object.

Traffic flow

The traffic flow layer shows congestion on the main route network. To show it:

tomTomMap.showTrafficFlow()
Traffic flow

To hide traffic flow:

tomTomMap.hideTrafficFlow()

Traffic incidents

To show traffic incidents on the map, call the TomTomMap.showTrafficIncidents() method.

tomTomMap.showTrafficIncidents()
Traffic incidents

To hide traffic incidents:

tomTomMap.hideTrafficIncidents()

Additionally, you can observe click actions performed on traffic incidents. To do this, set the TrafficIncidentClickListener listener to the TomTomMap object. If the user taps on a traffic incident, the listener method is triggered with the list of TrafficIncident objects and the GeoPoint of the clicked location. The TrafficIncident provides information about the incident such as a description of the cause (along with an icon category), delay in seconds, and when the incident is estimated to end.

1val trafficIncidentClickListener =
2 TrafficIncidentClickListener {
3 trafficIncidents: List<TrafficIncident>,
4 geoPoint: GeoPoint,
5 ->
6 // YOUR CODE GOES HERE
7 }
8tomTomMap.addTrafficIncidentClickListener(trafficIncidentClickListener)

Once the listener is no longer needed, it can be removed.

tomTomMap.removeTrafficIncidentClickListener(trafficIncidentClickListener)

Next steps

Since you have learned how to show traffic on the map, here are recommendations for the next steps: