Traffic

VERSION 0.44.1
PUBLIC PREVIEW

The TomTom Map Display SDK 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:

map.showTraffic()

To hide traffic flow:

map.hideTraffic()

Traffic incidents

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

map.showTrafficIncidents()

To hide traffic incidents:

map.hideTrafficIncidents()

Additionally, you can observe click actions performed on traffic incidents. To do this, register the TrafficIncidentObserver on the TomTomMap object.

map.registerTrafficIncidentObserver(self)

If the user taps on a traffic incident, the observer method is triggered with the list of TrafficIncident objects and the CLLocationCoordinate2D of the clicked location. The TrafficIncident provides information about the incident such as a description, delay in seconds, and when the incident is estimated to end.

1extension TrafficViewController: TrafficIncidentObserver {
2 func onTrafficIncidentClicked(trafficIncidents _: [TrafficIncident], coordinate _: CLLocationCoordinate2D) {
3 /* YOUR CODE GOES HERE */
4 }
5}