Maps SDK for Web

Provides current traffic incidents in a given region, on a given zoom level with a given style using the TomTom Traffic API - Traffic Incidents Details

The current road situation is updated every minute. Please use the IncidentViewport service in conjunction with your request to get traffic incidents aligned with other services.

Parameters need to be passed to the constructor. The method go performs the actual call.

The SDK provides a Promise polyfill for browsers (IE<9) without native ECMAScript 6 support.

The final response from this service is a GeoJSON object.


function callbackFn(response) {
  key: '<Your API key>',
  boundingBox: '0,0,1,1',
  style: 's1',
  zoomLevel: 12
Name Description
Object | Number[] | Object[] | String

Bounding box area in one of the supported formats.

The bounding box is a limited area within the search results. If it is omitted then the whole world will be taken into consideration. In case the area specified exceeds the world boundaries, the following actions will be taken depending on which side was exceeded:
  • Latitudes: the exceeded values will be replaced with their maximun.
  • Longitudes: The service will split the area into two (or more) valid bounding boxes, will execute a search request for each one, and then merge the responses into a single result.
This option is able to convert a number of popular formats into the bounding box. The supported formats are listed below:
  • Maps.LngLatBounds class instance
  • {minLon: 0, minLat: 0, maxLon: 1, maxLat: 1} A plain object with the keys minLon, minLat, maxLon, maxLat.
  • [0, 0, 1, 1] An array of numbers describing the bounding box following the order: minLon, minLat, maxLon, maxLat.
  • [[0, 0], [1, 1]] A two-dimensional array with two indexes [southWest, northEast], each one with longitude and latitude values.
  • "0,0,1,1" A comma-separated string with numbers in the order: minLon, minLat, maxLon, maxLat.
  • [{lon: 0, lat: 0},{lon: 1, lat: 1}] A one-dimensional array with two objects in the order: southWest, northEast, and each object with a lat and lon key.
  • [{lng: 0, lat: 0},{lng: 1, lat: 1}] A one-dimensional array with two objects in the order: southWest, northEast and each object with a lat and lon key.
  • [Maps.LngLat, Maps.LngLat] A one-dimensional array with two Maps.LngLat instances in the order: southWest and northEast.

Determines if the service should include details of incidents that are clustered.

Tells the service to separately list all traffic incidents in a cluster. When is enabled the clusters in the response will be represented as geometry collections, and the cluster coordinates will appear as clusterCoordinates parameters. Enabling this feature is useful when the user wants to obtain details of the incidents that are being clustered, or wants to perform a client-side clustering. Note that when this is set to false, the toGeoJson() method available in the resolved response will return only unclustered POIs, but no clusters.

A valid API Key for the requested service.

A valid API Key is required to make use of the given service. It can be issued in the Developer Portal.

Language code that decides in which language the results should be returned.

The value should correspond to one of the supported IETF language codes. The list is available here. The code is case insensitive.

Determines if the service should include the original incidents' position.

Return the original position of the incident (originalPosition attribute) as well as the one shifted to the beginning of the traffic tube.

Determines if clustered incidents data should be available in the cluster feature.

If this is set to true, the toGeoJson() method available in the resolved response will return features with an additional properties.features field containing clustered features. Note that this option only works in conjunction with expandCluster set to true.
"http" | "https"

The protocol type to be used in the calls.

Represents the type of protocol used to perform a service call.

Style name, needs to be one of 's1', 's2', 's3', 'night'. This needs to match the style of your raster traffic tiles to match traffic tubes with traffic icons.

The style that will be used to render the traffic tile in the Maps API. This will have an effect on the coordinates of traffic incidents in the reply.

A valid, not older than two minutes, traffic model ID.

Number referencing the traffic model to use. This can be obtained from the IncidentViewport service. It is updated every minute, and is valid for two minutes before it times out. If a wrong Traffic Model ID is specified, the correct one will be returned by the interface. The default value of -1 will always invoke the most recent traffic model. Nevertheless, it is good practice to use the value obtained from the service as this will guarantee an alignment with the raster traffic layer.

Zoom level from 0 to 22

The zoom level of a currently displayed map. It is needed as the style (visibility, clustering, etc...) depends on the current zoom level.


go( ): Promise

Executes a predefined asynchronous task using the current configuration.