ALKMaps.Strategy.MarkerCluster

Strategy for marker clustering.

Inherits from

Example

var markerClusterStrategy = new ALKMaps.Strategy.MarkerCluster({distance: 20, threshold: 2});
var markerLayer = new ALKMaps.Layer.Markers("Marker Layer", {attribution: "COPYRIGHT TEXT", strategies: [markerClusterStrategy]});
Summary
ALKMaps.Strategy.MarkerClusterStrategy 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.Strategy.ClusterCreate a new clustering strategy.
Functions
activateActivate the strategy.
deactivateDeactivate the strategy.
cacheMarkersCache markers before they are added to the layer.
clearCacheClear out the cached markers.
clusterCluster markers based on some threshold distance.
clustersExistDetermine whether calculated clusters are already on the layer.
shouldClusterDetermine whether to include a marker in a given cluster.
addToClusterAdd a marker to a cluster.
createClusterGiven a marker, create a cluster.

Properties

distance

{Integer} Pixel distance between markers that should be considered a single cluster.  Default is 20 pixels.

attribute

{String} Use it as the key to find the value in the marker attributes collection.  Markers that should be considered a single cluster when having a matching attribute value.

threshold

{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).

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.  Default: null (cluster at all levels)

displayClass

{String} CSS class for rendering clustered marker counts.

Constructor

ALKMaps.Strategy.Cluster

Create a new clustering strategy.

Parameters

options{Object} Optional object whose properties will be set on the instance.

Functions

activate

activate: function()

Activate the strategy.  Register any listeners, do appropriate setup.

Returns

{Boolean} The strategy was successfully activated.

deactivate

deactivate: function()

Deactivate the strategy.  Unregister any listeners, do appropriate tear-down.

Returns

{Boolean} The strategy was successfully deactivated.

cacheMarkers

cacheMarkers: function(event)

Cache markers before they are added to the layer.

Parameters

event{Object} The event that this was listening for.  This will come with a batch of markers to be clustered.

Returns

{Boolean} False to stop markers from being added to the layer.

clearCache

clearCache: function()

Clear out the cached markers.

cluster

cluster: function(event)

Cluster markers based on some threshold distance.

Parameters

event{Object} The event received when cluster is called as a result of a moveend event.

clustersExist

clustersExist: function()

Determine whether calculated clusters are already on the layer.

Returns

{Boolean} The calculated clusters are already on the layer.

shouldCluster

shouldCluster: function(cluster,
marker)

Determine whether to include a marker in a given cluster.

Parameters

cluster{ALKMaps.Marker2} A cluster.
marker{ALKMaps.Marker2} A marker.

Returns

{Boolean} The marker should be included in the cluster.

addToCluster

addToCluster: function(cluster,
marker)

Add a marker to a cluster.

Parameters

cluster{ALKMaps.Marker2} A cluster.
marker{ALKMaps.Marker2} A marker.

createCluster

createCluster: function(marker)

Given a marker, create a cluster.

Parameters

marker{ALKMaps.Marker2}

Returns

{ALKMaps.Marker2} A cluster.

Instances of ALKMaps.Marker2 are a combination of a div and other elements.
activate: function()
Activate the strategy.
deactivate: function()
Deactivate the strategy.
cacheMarkers: function(event)
Cache markers before they are added to the layer.
clearCache: function()
Clear out the cached markers.
cluster: function(event)
Cluster markers based on some threshold distance.
clustersExist: function()
Determine whether calculated clusters are already on the layer.
shouldCluster: function(cluster,
marker)
Determine whether to include a marker in a given cluster.
addToCluster: function(cluster,
marker)
Add a marker to a cluster.
createCluster: function(marker)
Given a marker, create a cluster.
Abstract vector layer strategy class.
Close