Strategy for marker clustering.
var markerClusterStrategy = new ALKMaps.Strategy.MarkerCluster({distance: 20, threshold: 2});
var markerLayer = new ALKMaps.Layer.Markers("Marker Layer", {attribution: "COPYRIGHT TEXT", strategies: [markerClusterStrategy]});| ALKMaps. | Strategy for marker clustering. |
| Properties | |
| distance | {Integer} Pixel distance between markers that should be considered a single cluster. |
| attribute | {String} Use it as the key to find the value in the marker attributes collection. |
| threshold | {Integer} Optional threshold below which original markers will be added to the layer instead of clusters. |
| markers | {Array(ALKMaps.Marker2)} Cached markers. |
| clusters | {Array(ALKMaps.Marker2)} Calculated clusters. |
| clustering | {Boolean} The strategy is currently clustering markers. |
| resolution | {Float} The resolution (map units per pixel) of the current cluster set. |
| maxZoomLevel | {Number} Indicates the maximum zoom level at which markers will be clustered. |
| displayClass | {String} CSS class for rendering clustered marker counts. |
| Constructor | |
| ALKMaps. | Create a new clustering strategy. |
| Functions | |
| activate | Activate the strategy. |
| deactivate | Deactivate the strategy. |
| cacheMarkers | Cache markers before they are added to the layer. |
| clearCache | Clear out the cached markers. |
| cluster | Cluster markers based on some threshold distance. |
| clustersExist | Determine whether calculated clusters are already on the layer. |
| shouldCluster | Determine whether to include a marker in a given cluster. |
| addToCluster | Add a marker to a cluster. |
| createCluster | Given a marker, create a cluster. |
{Integer} Optional threshold below which original markers will be added to the layer instead of clusters. For example, a threshold of 3 would mean that any time there are 2 or fewer markers in a cluster, those markers will be added directly to the layer instead of a cluster representing those markers. Default is null (which is equivalent to 1 - meaning that clusters may contain just one marker).
{Array(ALKMaps.Marker2)} Cached markers.
{Array(ALKMaps.Marker2)} Calculated clusters.
shouldCluster: function( cluster, marker )
Determine whether to include a marker in a given cluster.
| cluster | {ALKMaps.Marker2} A cluster. |
| marker | {ALKMaps.Marker2} A marker. |
{Boolean} The marker should be included in the cluster.
addToCluster: function( cluster, marker )
Add a marker to a cluster.
| cluster | {ALKMaps.Marker2} A cluster. |
| marker | {ALKMaps.Marker2} A marker. |
createCluster: function( marker )
Given a marker, create a cluster.
| marker | {ALKMaps.Marker2} |
{ALKMaps.Marker2} A cluster.
Activate the strategy.
activate: function()
Deactivate the strategy.
deactivate: function()
Cache markers before they are added to the layer.
cacheMarkers: function( event )
Clear out the cached markers.
clearCache: function()
Cluster markers based on some threshold distance.
cluster: function( event )
Determine whether calculated clusters are already on the layer.
clustersExist: function()
Determine whether to include a marker in a given cluster.
shouldCluster: function( cluster, marker )
Add a marker to a cluster.
addToCluster: function( cluster, marker )
Given a marker, create a cluster.
createCluster: function( marker )