ALKMaps.Strategy.Cluster

Strategy for vector feature clustering.

Inherits from

Summary
ALKMaps.Strategy.ClusterStrategy for vector feature clustering.
Properties
distance{Integer} Pixel distance between features that should be considered a single cluster.
attribute{String} Use it as the key to find the value in the feature attributes collection.
rule{ALKMaps.Rule} with {ALKMaps.Filter.Comparison} as filter option.
threshold{Integer} Optional threshold below which original features will be added to the layer instead of clusters.
features{Array(ALKMaps.Feature.Vector)} Cached features.
clusters{Array(ALKMaps.Feature.Vector)} Calculated clusters.
clustering{Boolean} The strategy is currently clustering features.
resolution{Float} The resolution (map units per pixel) of the current cluster set.
maxZoomLevel{Number} Indicates the maximum zoom level at which vectors will be clustered.
Constructor
ALKMaps.Strategy.ClusterCreate a new clustering strategy.
Functions
activateActivate the strategy.
deactivateDeactivate the strategy.
cacheFeaturesCache features before they are added to the layer.
clearCacheClear out the cached features.
clusterCluster features based on some threshold distance.
reclusterUser-callable function to recluster features Useful for instances where a clustering attribute (distance, threshold, ...)
clustersExistDetermine whether calculated clusters are already on the layer.
shouldClusterDetermine whether to include a feature in a given cluster.
addToClusterAdd a feature to a cluster.
createClusterGiven a feature, create a cluster.

Properties

distance

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

attribute

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

rule

{ALKMaps.Rule} with {ALKMaps.Filter.Comparison} as filter option.  Use the rule to decide that a feature is a part of cluster.

threshold

{Integer} Optional threshold below which original features 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 features in a cluster, those features will be added directly to the layer instead of a cluster representing those features.  Default is null (which is equivalent to 1 - meaning that clusters may contain just one feature).

features

{Array(ALKMaps.Feature.Vector)} Cached features.

clusters

{Array(ALKMaps.Feature.Vector)} Calculated clusters.

clustering

{Boolean} The strategy is currently clustering features.

resolution

{Float} The resolution (map units per pixel) of the current cluster set.

maxZoomLevel

{Number} Indicates the maximum zoom level at which vectors will be clustered.  Default: null (cluster at all levels)

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.

cacheFeatures

cacheFeatures: function(event)

Cache features before they are added to the layer.

Parameters

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

Returns

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

clearCache

clearCache: function()

Clear out the cached features.

cluster

cluster: function(event)

Cluster features based on some threshold distance.

Parameters

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

recluster

recluster: function()

User-callable function to recluster features Useful for instances where a clustering attribute (distance, threshold, ...) has changed or when new features dynamically added to layer.

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,
feature)

Determine whether to include a feature in a given cluster.

Parameters

cluster{ALKMaps.Feature.Vector} A cluster.
feature{ALKMaps.Feature.Vector} A feature.

Returns

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

addToCluster

addToCluster: function(cluster,
feature)

Add a feature to a cluster.

Parameters

cluster{ALKMaps.Feature.Vector} A cluster.
feature{ALKMaps.Feature.Vector} A feature.

createCluster

createCluster: function(feature)

Given a feature, create a cluster.

Parameters

feature{ALKMaps.Feature.Vector}

Returns

{ALKMaps.Feature.Vector} A cluster.

Vector features use the ALKMaps.Geometry classes as geometry description.
activate: function()
Activate the strategy.
deactivate: function()
Deactivate the strategy.
cacheFeatures: function(event)
Cache features before they are added to the layer.
clearCache: function()
Clear out the cached features.
cluster: function(event)
Cluster features based on some threshold distance.
recluster: function()
User-callable function to recluster features Useful for instances where a clustering attribute (distance, threshold, ...)
clustersExist: function()
Determine whether calculated clusters are already on the layer.
shouldCluster: function(cluster,
feature)
Determine whether to include a feature in a given cluster.
addToCluster: function(cluster,
feature)
Add a feature to a cluster.
createCluster: function(feature)
Given a feature, create a cluster.
Abstract vector layer strategy class.
Close