SDK for iOS Developer's Guide

Traffic Information

SDK for iOS offers real-time traffic flow and congestion overlays. Traffic information can be displayed on the NMAMapView (where available) by setting its trafficInfoVisible property to YES. While HERE SDK requires network data connection to download real time traffic information, the visualization may continue to be displayed even if a connection is lost — until the traffic events expire, or the visibility is toggled.

Note: If you set trafficInfoVisible property to YES in NMAMapView, you need to switch the map view to one of the following schemes.
  • NMAMapSchemeNormalDayWithTraffic
  • NMAMapSchemeNormalNightWithTraffic
  • NMAMapSchemeHybridDayWithTraffic
  • NMAMapSchemeHybridNightWithTraffic
  • NMAMapSchemeCarNavigationDayWithTraffic
  • NMAMapSchemeCarNavigationNightWithTraffic
  • NMAMapSchemeHybridCarNavigationDayWithTraffic
For more information on map schemes see Map Schemes

Traffic visualization is refreshed when one of the following happens:

  1. The map is moved by a significant distance
  2. The map is not moved for 1 minute. This duration can be set using setRefreshInterval in NMATrafficManager

Traffic Flow

Traffic flow lines are color-coded as follows:

  • Green - Normal
  • Amber - High
  • Red - Very High
  • Black - Blocking

The following figure provides an example of traffic visualization:

Figure 1. Traffic information with color-coded lines

You can control the display of traffic flow lines via trafficDisplayFilter property on NMAMapView.

For example, you can set the map to only display traffic flow lines that are "very high" (red) or "blocking" (black) by performing the following:

// set the minimum displayed traffic level
mapView.trafficDisplayFilter = NMATrafficSeverityVeryHigh;

Traffic Flow Example on GitHub

You can find an example that demonstrates this feature at https://github.com/heremaps/ (Obj-C) and https://github.com/heremaps/ (Swift).

Traffic Incidents

The traffic information updates contain live traffic event information; these events are represented by various icons on the map. The following figures show examples of different types of traffic events:

Figure 2. NMATrafficObject example: Roadwork
Figure 3. NMATrafficObject example: Accident
Figure 4. NMATrafficObject example: Road Closed

Traffic Objects and Events

Traffic events are represented on the map using instances of the NMATrafficObject proxy object class. These objects may be selected either by tapping on the map (which returns the objects from -mapView:didSelectObjects: method in the NMAMapViewDelegate protocol) or by calling -objectsAtPoint: method in NMAMapView. The underlying event is represented by an instance of NMATrafficEvent, which may be accessed via trafficEvent property in NMATrafficObject. The properties in NMATrafficEvent contain information about the event including type, description, and affected streets.