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 Germany, 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 Map Tile API. It automatically adds layers using traffic map tiles 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
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.