TrafficIncidents Layer

The ALKMaps.Layer.TrafficIncidents layer allows you to display current traffic incidents. There are two parameters for the constructor, the name/id you wish to give your layer and the object containing all of your layer option settings. For a detailed description of all possible options, please reference the table below.

Option Type/Values Description
threshold number Minimum feature threshold for the layer's cluster strategy. Default 5.
distance number Minimum pixel distance between features for the layer's cluster strategy. Default 30.
cluster boolean Indicates whether or not the layer should be clustered. Default true.
strategies ALKMaps.Strategy.Cluster User can provide custom layer strategies to replace default ones.
styleMap ALKMaps.StyleMap User can provide custom style map for the layer.
minZoomLevel number Minimum zoom level for retrieving and displaying traffic incidents. Default 5.
cacheInterval number Time in minutes indicating how long the traffic incidents will refresh. Default 10.

Default Category Images

Category Image

Displaying Popups

In order to have the popups/tooltips display on hover and/or click accordingly, you will need to define an ALKMaps.Control.FeatureEvent control with the appropriate listeners. For further assistance implementing this, please reference the sample code below.

var featureEvent = new ALKMaps.Control.FeatureEvent([trafficIncidents],
        geometryTypes: ["ALKMaps.Geometry.Point"],


var onHover = function(evt) {
    // Shows tool tip when mouse over an incident
    return trafficIncidents.onmouseover(evt.feature);

var onClick = function(evt) {
    // Shows incidents description when clicking an incident.
    return trafficIncidents.onmouseclick(evt.feature);
};"overFeature", trafficIncidents, onHover);"featureclicked", trafficIncidents, onClick);

To view a live demo of the Traffic Incidents layer with working popups and some useful techniques for customizing your layer, please visit the Traffic Incidents example page and view the source code.