alk.layer.TrafficLayer layer is used to display live or historic traffic data on the map. Traffic is color coded to indicate the severity of the traffic on a particular road. Green meaning light or no traffic, yellow for medium traffic, and red indicating the heaviest traffic.
The available options for this layer are explained in the table below.
|Data region for the traffic data. Default: |
|The histDay parameter is set to a string containing name of the day of the week. Valid values are:|
|The histTimeBin parameter is set to an integer representing a 15 minute block of time during the day. There are a 96 total 15 minute time bins for the day beginning with midnight as 0. Valid values are integers from 0 to 95. Some common time bin values are:|
|The histTimeZone parameter is the offset from UTC for the time zone. If omitted, UTC is assumed. The colon between the hours and minutes is required. See ISO 8601 for more details.
Some common time zone offsets are:|
|The opacity of the layer. Default: |
To pull historical traffic data for a specific day and time, you'll need to set the appropriate parameters (histDay, histTimeBin, and histTimeZone) on the layer.
To display the historical traffic data for a Tuesday at 7pm EDT, you would use the following code
By default the traffic layer will default to the North America(“NA”), you can change this by specifying the region property of the parameters object.