The ALKMaps.Layer.TrafficCameras
layer allows you display current traffic cameras and images within given bounds.
There are two parameters for the constructor, the name 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 . Minimum 5 cameras in a cluster.
|
distance |
number |
Minimum pixel distance between cameras for the layer's cluster strategy. Default 30 .
|
cluster |
boolean |
Indicates whether or not the layer should be clustered. Default true . threshold , distance and cluster only apply to the built-in default strategy. If strategies is provided, then they will be ignored.
|
strategies |
Array(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. |
cacheInterval |
number |
The time duration in minutes that traffic cameras should be cached. Default 480 , 8 hours. After this time interval has been passed and map have been moved, the layer may try to replace all existing cameras. |
In order to have a camera responsive to mouse click or over event, you will need to define an ALKMaps.Control.FeatureEvent
control with the appropriate listeners. For further assistance implimenting this, please reference the sample code below.
var featureEvent = new ALKMaps.Control.FeatureEvent([trafficCameras], { geometryTypes: ["ALKMaps.Geometry.Point"], }); map.addControl(featureEvent); featureEvent.activate(); var onHover = function(evt){ // Shows tool tip when mouse over a camera return trafficCameras.onmouseover(evt.feature); }; var onClick = function(evt){ // Shows camera image when clicking a camera. return trafficCameras.onclick(evt.feature); }; trafficCameras.events.register("overFeature", trafficCameras, onHover); trafficCameras.events.register("featureclicked", trafficCameras, onClick);
To view a live demo of the Traffic Cameras layer with working popups and some useful techniques for customizing your layer, please visit the Traffic Cameras example page and view the source code.