public class

ClusteredVectorLayer

extends VectorLayer
java.lang.Object
   ↳ com.carto.layers.Layer
     ↳ com.carto.layers.VectorLayer
       ↳ com.carto.layers.ClusteredVectorLayer

Class Overview

A vector layer that supports clustering point-type features.
A Pairwise centroid hierarchical clustering algorithm is used internally.

Summary

Public Constructors
ClusteredVectorLayer(LocalVectorDataSource dataSource, ClusterElementBuilder clusterElementBuilder)
Constructs a new ClusteredVectorLayer instance from data source and a special callback.
Public Methods
synchronized void delete()
boolean expandCluster(VectorElement clusterElement, float px)
Expands or shrinks the given cluster element.
ClusterElementBuilder getClusterElementBuilder()
Returns the current callback used for creating cluster elements.
float getMaximumClusterZoom()
Returns the maximum zoom level when clusters are shown.
float getMinimumClusterDistance()
Returns the current minimum distance between clusters (in device-independent pixels).
boolean isAnimatedClusters()
Returns the cluster animation flag value.
void refresh()
Refreshes the layer using old stored visibility information.
void setAnimatedClusters(boolean animated)
Enables or disables the animation of clusters.
void setMaximumClusterZoom(float maxZoom)
Sets the maximum zoom level when clusters are shown.
void setMinimumClusterDistance(float px)
Sets the minimum distance between clusters (in device-independent pixels).
[Expand]
Inherited Methods
From class com.carto.layers.VectorLayer
From class com.carto.layers.Layer
From class java.lang.Object

Public Constructors

public ClusteredVectorLayer (LocalVectorDataSource dataSource, ClusterElementBuilder clusterElementBuilder)

Constructs a new ClusteredVectorLayer instance from data source and a special callback.

Parameters
dataSource The local data source that contains the elements for clustering.
clusterElementBuilder The callback for creating and customizing cluster elements.

Public Methods

public synchronized void delete ()

public boolean expandCluster (VectorElement clusterElement, float px)

Expands or shrinks the given cluster element. In expanded state,
all elements of the cluster are placed at specified distance from the cluster center.

Parameters
clusterElement The cluster element to expand or shrink.
px The distance (in device-independent pixels) between cluster center and expanded elements. Use 0 to shrink already expanded cluster.
Returns
  • True if the element was found and expanded/shrunk. False otherwise.

public ClusterElementBuilder getClusterElementBuilder ()

Returns the current callback used for creating cluster elements.

Returns
  • The associated callback.

public float getMaximumClusterZoom ()

Returns the maximum zoom level when clusters are shown. If zoom level is greater, then
clusters are replaced with individual elements. Default is 24.

Returns
  • The maximum clustering zoom level.

public float getMinimumClusterDistance ()

Returns the current minimum distance between clusters (in device-independent pixels).

Returns
  • The current minimum clustering distance.

public boolean isAnimatedClusters ()

Returns the cluster animation flag value.

Returns
  • True if animation is enabled, false otherwise.

public void refresh ()

Refreshes the layer using old stored visibility information. This method might be called if some of the layer data
changes.

public void setAnimatedClusters (boolean animated)

Enables or disables the animation of clusters. By default animations are enabled.

Parameters
animated The animated flag.

public void setMaximumClusterZoom (float maxZoom)

Sets the maximum zoom level when clusters are shown. If zoom level is greater, then
clusters are replaced with individual elements.

Parameters
maxZoom The new maximum clustering zoom level.

public void setMinimumClusterDistance (float px)

Sets the minimum distance between clusters (in device-independent pixels).

Parameters
px The new value in device-independent pixels. The default is 100.