Traffic

VERSION 0.2.1455
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:

tomTomMap.showTraffic()

To hide traffic flow:

tomTomMap.hideTraffic()

Traffic incidents

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

tomTomMap.showTrafficIncidents()

To hide traffic incidents:

tomTomMap.hideTrafficIncidents()

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

tomTomMap.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: OnTrafficIncidentObservation {
2 func onTrafficIncidentClicked(trafficIncidents _: [TrafficIncident], coordinate _: CLLocationCoordinate2D) {
3 /* YOUR CODE GOES HERE */
4 }
5}