All Implemented Interfaces:
Serializable

public class ClusterSource extends VectorSource
A source that clusters features within a certain distance.

Currently only point-based features such as MarkerFeature are supported.

Note: There should be no need to construct this class directly. Instead, use a FeatureLayer which exposes the same API as this source. Clustering can be enabled in a feature layer using FeatureLayer.setClusteringEnabled(boolean).

See Also:
  • Constructor Details

    • ClusterSource

      public ClusterSource()
      Creates a new cluster source.
    • ClusterSource

      public ClusterSource(VectorSource.Options options)
      Creates a new cluster source with custom options.
      Parameters:
      options - the options for the cluster source
  • Method Details

    • getType

      public String getType()
      Description copied from class: AbstractConfigurationObject
      The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.
      Overrides:
      getType in class VectorSource
    • addFeature

      public void addFeature(Feature feature)
      Adds a feature to this source. Only point-based features such as MarkerFeature are supported. Throws for other feature types.
      Overrides:
      addFeature in class VectorSource
      Parameters:
      feature - the feature to add
    • getDistance

      public int getDistance()
      The distance in pixels within which features should be clustered. Default is 50 pixels.
      Returns:
      the distance in pixels within which features should be clustered
    • setDistance

      public void setDistance(int distance)
      Sets the distance in pixels within which features should be clustered.
      Parameters:
      distance - the distance in pixels within which features should be clustered
    • getMinDistance

      public int getMinDistance()
      Minimum distance in pixels between clusters. Will be capped at the configured distance. By default, no minimum distance is guaranteed. This config can be used to avoid overlapping icons. As a trade-off, the cluster feature's position will no longer be the center of all its features. Default is 50 pixels.
      Returns:
      the minimum distance in pixels between clusters
    • setMinDistance

      public void setMinDistance(int minDistance)
      Sets the minimum distance in pixels between clusters.
      Parameters:
      minDistance - the minimum distance in pixels between clusters