Skip to main content

TrafficIncidents Layer

The alk.layer.TrafficIncidentsLayer layer allows you to display current traffic incidents.

Default Category Images

Category Image
Traffic icon
Accident icon
Weather icon
Roadworks icon
Default icon

Clustering Incidents

Displaying Popups

In order to have the popups/tooltips display on hover and/or click accordingly, you will need to define an alk.interaction.TrafficIncidentPopupInteraction interaction control.

var baseMap = new alk.layer.BaseMapLayer();
var trafficIncidents = new alk.layer.TrafficIncidentsLayer();
var popupInteraction = new alk.interaction.TrafficIncidentPopupInteraction();
var map = new ol.Map({
  target: "map",
  layers: [baseMap, trafficIncidents],
  view: new ol.View({
    center: ol.proj.transform(
      [-73.996, 40.729],
      alk.val.SRS.EPSG4326,
      alk.val.SRS.EPSG3857
    ),
    zoom: 12
  }),
  interactions: ol.interaction.defaults().extend([popupInteraction])
});
Last updated November 23, 2021.