Maps SDK for Web

tt.TrafficIncidentTier

This tier provides both traffic incidents details and tiles information.

var map = tt.map({
 //your map configuration
});
map.on('load', function() {
    map.addTier(new tt.TrafficIncidentTier({
        key: <api key>,//your traffic incidents api key goes here
        incidentDetails: true, //or provide more detailed configuration
        incidentTiles: true //or provide more detailed configuration
    }))
});

Methods

constructor(options)

Parameters
Name Description
options
Object
default:None
Traffic incidents options.
options.key
String
default:None
Traffic incident api key. This key is shared between traffic incident details and tiles services.
options.incidentDetails
Object
default:None
All options for Incident Details service, which are documented here. Additional options can be found below.
options.incidentDetails.style
String
default:None
Style of traffic incidents details (may change their position). Supported values are: s0, s0-dark, s1, s2 and s3.
options.incidentDetails.markerOptions.units
String
default: 'metric'
Measurements units. Supported values: 'metric', 'imperial'.
options.incidentDetails.markerOptions.markerFactory
Function
default:None
A factory method for creating marker instances. This method may have two parameters: * a feature representing incident (regular or clustered) * a default factory method which may be invoked to build a default marker for a given incident. * an optional instance of an old marker which can be updated This method needs to return a {{#crossLink "Maps.Marker"}}{{/crossLink}} instance or null. The latter will cause that given incident will not be rendered on a map.
options.incidentDetails.markerOptions.cluster.disableOnClickBehavior
Boolean
default: false
The flag which allows you to disable default on 'click' behavior for cluster markers
options.incidentDetails.cssStyleCheck
Boolean
default:true
If true, the tier will check if required css styles are added.
options.incidentTiles.style
String
default:'tomtom://vector/1/s1'
The traffic incident tiles style. It can be one of following types:
  • Schema, you can use of following values:
    1. tomtom://vector/1/s0
    2. tomtom://vector/1/s0-dark
    3. tomtom://vector/1/s1
    4. tomtom://vector/1/s2
    5. tomtom://vector/1/s3
    6. tomtom://raster/1/s0
    7. tomtom://raster/1/s0-dark
    8. tomtom://raster/1/s1
    9. tomtom://raster/1/s2
    10. tomtom://raster/1/s3
  • URL to the JSON object conforming to the schema described in the Map Style Specification.
  • JSON object conforming to the mentioned specification.
options.refresh
Number
default:30000
The interval in milliseconds between subsequent refreshes of traffic incident information. Any value lower than 30000 will be treated as 30000. This interval affects both traffic incident details and tiles services.

Events

All the class events are keys of the Events static member.

To learn more about how to listen events please refer to the Evented class.

tomtom.trafficIncidents.detailsUpdated

Fired immediately after incidents are fetched and a map is updated. An event instance contains following fields:
  • trafficIncidents - data returned by the traffic incident service
  • markers - an object where keys are ids of incidents and values are markers (instances of Maps.Marker) representing those incidents on a map.