HERE Android SDK Developer's Guide

Traffic Information

Traffic information can be displayed on the Map, depending on traffic data availability, by using Map.setTrafficInfoVisible(true) and setting the map to a traffic-enabled map scheme . Traffic visualization requires a network data connection to download real time traffic information. However, traffic information may continue to be displayed thereafter without a connection until the traffic events expire or the visibility is toggled.

The current traffic-enabled map schemes are:
  • Map.Scheme.HYBRID_TRAFFIC_DAY
  • Map.Scheme.HYBRID_TRAFFIC_NIGHT
  • Map.Scheme.NORMAL_TRAFFIC_DAY
  • Map.Scheme.NORMAL_TRAFFIC_NIGHT
  • Map.Scheme.CARNAV_TRAFFIC_DAY
  • Map.Scheme.CARNAV_TRAFFIC_NIGHT
  • Map.Scheme.CARNAV_TRAFFIC_HYBRID_DAY
  • Map.Scheme.CARNAV_TRAFFIC_HYBRID_NIGHT

The following figure shows a sample traffic visualization.

Figure 1. Traffic information with color-coded lines

Traffic flow lines are color coded as follows:

Green Normal
Amber High
Red Very High
Black Blocking

Controlling Traffic Display

You can further control traffic display by calling Map.getMapTrafficLayer() and using the MapTrafficLayer object.

With MapTrafficLayer, you can individually disable Traffic Flow, Traffic Incidents, or On-Route Traffic, as well as filter traffic that is displayed according to the minimal severity level.

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:

MapTrafficLayer traffic = map.getMapTrafficLayer();
//set the minimum displayed traffic level
traffic.setDisplayFilter(TrafficEvent.Severity.VERY_HIGH);

Traffic Objects and Events

Traffic events are selectable through map gestures and OnGestureListener.onMapObjectsSelected(List<ViewObject>). A user selectable TrafficEventObject contains live traffic event information and is presented on the map in different forms. The following figures illustrate three examples:

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

To acquire information about a tapped TrafficEventObject (see MapObjects), use onMapObjectsSelected(List<ViewObject>) as in the following:


private MapGesture.OnGestureListener listener = new MapGesture.OnGestureListener() {
  ...
  @Override
  public boolean onMapObjectsSelected(List<ViewObject> objects) {
    for (ViewObject obj : objects) {
      if (obj.getBaseType() == ViewObject.Type.PROXY_OBJECT) {
        MapProxyObject proxyObj = (MapProxyObject) obj;
        if (proxyObj.getType() == MapProxyObject.Type.TRAFFIC_EVENT) {
          TrafficEventObject trafficEventObj =
                 (TrafficEventObject) proxyObj;
          TrafficEvent trafficEvent =
                  trafficEventObj.getTrafficEvent();
          Toast.makeText(getApplicationContext(), trafficEvent.getEventText(),
                  Toast.LENGTH_LONG).show();
        }
      }
    }

  return true;
};