OpenLayers.Strategy.Cluster - OpenLayers

# OpenLayers. Strategy. Cluster

Strategy for vector feature clustering.

#### Inherits from

- OpenLayers.Strategy

Summary

OpenLayers. Strategy. Cluster | Strategy for vector feature clustering.
Properties |
layer | {OpenLayers.Layer.Vector} The layer that this strategy is assigned to.
distance | {Integer} Pixel distance between features that should be considered a single cluster.
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.
Functions |
activate | Activate the strategy.
deactivate | Deactivate the strategy.
cacheFeatures | Cache features before they are added to the layer.
clearCache | Clear out the cached features.
cluster | Cluster features based on some threshold distance.
clustersExist | Determine whether calculated clusters are already on the layer.
shouldCluster | Determine whether to include a feature in a given cluster.
addToCluster | Add a feature to a cluster.
createCluster | Given a feature, create a cluster.

### Properties

### layer

{OpenLayers.Layer.Vector} The layer that this strategy is assigned to.

### distance

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

### 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. This destroys features, assuming nothing else has a reference.

### cluster

> cluster: function()

Cluster features based on some threshold distance.

### 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.

Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
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()

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