OpenLayers.Strategy.Cluster

Strategy for vector feature clustering.

Inherits from

Summary
OpenLayers.Strategy.ClusterStrategy for vector feature clustering.
Properties
distance{Integer} Pixel distance between features that should be considered a single cluster.
threshold{Integer} Optional threshold below which original features will be added to the layer instead of clusters.
features{Array(OpenLayers.Feature.Vector)} Cached features.
clusters{Array(OpenLayers.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.
Constructor
OpenLayers.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.
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.

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(OpenLayers.Feature.Vector)} Cached features.

clusters

{Array(OpenLayers.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.

Constructor

OpenLayers.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 layer 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.

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{OpenLayers.Feature.Vector} A cluster.
feature{OpenLayers.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{OpenLayers.Feature.Vector} A cluster.
feature{OpenLayers.Feature.Vector} A feature.

createCluster

createCluster: function(feature)

Given a feature, create a cluster.

Parameters

feature{OpenLayers.Feature.Vector}

Returns

{OpenLayers.Feature.Vector} A cluster.

Vector features use the OpenLayers.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.
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