Traffic

VERSION 0.3.1106
PUBLIC PREVIEW

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 OnTrafficIncidentClickListener 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 onTrafficIncidentClickListener = OnTrafficIncidentClickListener {
2 trafficIncidents: List<TrafficIncident>,
3 geoPoint: GeoPoint ->
4 /* YOUR CODE GOES HERE */
5}
6tomTomMap.addOnTrafficIncidentClickListener(onTrafficIncidentClickListener)

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

tomTomMap.removeOnTrafficIncidentClickListener(onTrafficIncidentClickListener)

Next steps

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