TrafficIncidents

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.

OptionType/ValuesDescription
thresholdnumberMinimum feature threshold for the layer’s cluster strategy. Default 5.
distancenumberMinimum pixel distance between features for the layer’s cluster strategy. Default 30.
clusterbooleanIndicates whether or not the layer should be clustered. Default true.
strategiesALKMaps.Strategy.ClusterUser can provide custom layer strategies to replace default ones.
styleMapALKMaps.StyleMapUser can provide custom style map for the layer.
minZoomLevelnumberMinimum zoom level for retrieving and displaying traffic incidents. Default 5.
cacheIntervalnumberTime in minutes indicating how long the traffic incidents will refresh. Default 10.
languagestringThe desired language for how traffic incidents will be displayed. If no value is set, the browser’s language setting will be used. English is the fallback language if the desired language is unavailable.

Available languages include: English (en), French (fr), Spanish (es), German (de), Italian (it), Swedish (sv), Danish (da), Norwegian (no), Finnish (fi), Dutch (nl), Slovak (sk), Polish (pl), Russian (ru), Turkish (tr), Portuguese (pt).

Default Category Images

CategoryImage
Trafficicon
Accidenticon
Weathericon
Roadworksicon
Defaulticon

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"]
});

map.addControl(featureEvent);
featureEvent.activate();

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);
};

trafficIncidents.events.register("overFeature", trafficIncidents, onHover);
trafficIncidents.events.register("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.