The Maps API provides a means of retrieving and displaying traffic data on the map for major urban areas around the globe.
Showing Traffic Flow on the Map
The example below uses the traffic component in the Maps API to show a map of part of Berlin, indicating the traffic conditions. Roads where traffic flows freely are marked in green, roads where congestion is moderate are in orange, while those that are congested are shown in red.
The API provides access to map tiles with traffic information through the HERE Traffic API. It automatically adds the flow layer to the default layer collection (accessed through the method
createDefaultLayers() on the
H.service.Platform instance). The application user can switch the traffic flow information display on and off for the available map types via the
The code below adds to the map the flow layer available in the default layer collection.
Showing Traffic Incidents on the Map
In addition to traffic flow, the API integrates traffic incident data by providing a marker overlay that can be added to the map.
The code below adds to the map the pre-configured traffic incidents marker layer available in the default layer collection to show traffic incidents.
This code assumes that
map is a previously instantiated and initialized instance of
MapSettingsControl includes an entry for switching traffic incidents display on and off if the traffic incident layer is detected in the collection of layers passed to the UI.