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.
NMAMapView, you need to switch the map view to one of the following schemes.
Traffic visualization is refreshed when one of the following happens:
- The map is moved by a significant distance
- The map is not moved for 1 minute. This duration can be set using
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:
You can control the display of traffic flow lines via
trafficDisplayFilter property on
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).
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:
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.