Maps SDK for Web
Class L.TomTomVectorTrafficFlowLayer
Tile layer for Leaflet that uses the Vector Flow Tiles from Traffic API.
The current vector renderer implementation is based on the Mapbox GL JS library.
Constructor
L.TomTomVectorTrafficFlowLayer([options.style="absolute"], [options.key], [options.refresh=30000])
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
options.style | Specifies the style and type of Traffic Flow | No | "absolute" | "relative" | "relative-delay" | "absolute" |
options.key | Traffic Flow API key that can be obtained from TomTom's developer portal. | No | String | None |
options.refresh | Traffic refresh inteval in milliseconds. The default value is 30 seconds. If a lower value is provided the default value is used. | No | Integer | 30000 |
Example
var ttVectorTrafficLayer = new L.TomTomVectorTrafficFlowLayer({
key: '<Your Traffic Flow API key>',
refresh: 30000,
basePath: '<SDK base path>',
style: 'relative'
});
map.addLayer(ttVectorTrafficLayer);
Properties
name: String
Default: "vectorTrafficFlow"
Name of the vector traffic flow layer. It can be used to differentiate layers.
Methods
getStyle( ): Object
Returns the vector style object currently applied to the vector layer.
Returns
A object with the current style or undefined if no style was applied yet.
setStyle(style)
Sets the style for the vector layer.
It expects an object formatted in compliance with the Mapbox style specification.
Parameters
Name | Description | Required | Type/Values | Default |
---|---|---|---|---|
style | object which will be applied to vectorLayer | Yes | Object | None |
Events
All the class events are keys of the Events static member.
To learn more about how to listen events please refer to this documentation.
MAP_ERROR : String
Fired when an error occurs during the initialization of the vector layer.
STYLE_LOAD_END : String
Fired immediately after the style was fully loaded.