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.style
String default:None |
Style of traffic incidents details (may change their position).
Supported values are: 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:
|
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:
|
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. |
getId( ): String
Returns tier's ID
Returns
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.