Package com.massifmaps.layers
Class ClusteredVectorLayer
java.lang.Object
com.massifmaps.layers.Layer
com.massifmaps.layers.VectorLayer
com.massifmaps.layers.ClusteredVectorLayer
A vector layer that supports clustering point-type features.
A Pairwise centroid hierarchical clustering algorithm is used internally.
A Pairwise centroid hierarchical clustering algorithm is used internally.
-
Constructor Summary
ConstructorsConstructorDescriptionClusteredVectorLayer(LocalVectorDataSource dataSource, ClusterElementBuilder clusterElementBuilder) Constructs a new ClusteredVectorLayer instance from data source and a special callback. -
Method Summary
Modifier and TypeMethodDescriptionbooleanexpandCluster(VectorElement clusterElement, float px) Expands or shrinks the given cluster element.Returns the current callback used for creating cluster elements.floatReturns the maximum zoom level when clusters are shown.floatReturns the current minimum distance between clusters (in device-independent pixels).booleanReturns the cluster animation flag value.voidrefresh()Refreshes the layer using old stored visibility information.voidsetAnimatedClusters(boolean animated) Enables or disables the animation of clusters.voidsetMaximumClusterZoom(float maxZoom) Sets the maximum zoom level when clusters are shown.voidsetMinimumClusterDistance(float px) Sets the minimum distance between clusters (in device-independent pixels).Methods inherited from class com.massifmaps.layers.VectorLayer
getDataSource, getVectorElementEventListener, isUpdateInProgress, isZBuffering, setVectorElementEventListener, setZBufferingMethods inherited from class com.massifmaps.layers.Layer
containsMetaDataKey, equals, getMetaData, getMetaDataElement, getOpacity, getUpdatePriority, getVisibleZoomRange, hashCode, isPostProcessed, isVisible, setCullDelay, setMetaData, setMetaDataElement, setOpacity, setPostProcessed, setUpdatePriority, setVisible, setVisibleZoomRange, simulateClick, update
-
Constructor Details
-
ClusteredVectorLayer
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.
-
-
Method Details
-
getClusterElementBuilder
Returns the current callback used for creating cluster elements.- Returns:
- The associated callback.
-
getMinimumClusterDistance
public float getMinimumClusterDistance()Returns the current minimum distance between clusters (in device-independent pixels).- Returns:
- The current minimum clustering distance.
-
setMinimumClusterDistance
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.
-
getMaximumClusterZoom
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.
-
setMaximumClusterZoom
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.
-
isAnimatedClusters
public boolean isAnimatedClusters()Returns the cluster animation flag value.- Returns:
- True if animation is enabled, false otherwise.
-
setAnimatedClusters
public void setAnimatedClusters(boolean animated) Enables or disables the animation of clusters. By default animations are enabled.- Parameters:
animated- The animated flag.
-
expandCluster
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.
-
refresh
public void refresh()Description copied from class:LayerRefreshes the layer using old stored visibility information. This method might be called if some of the layer data
changes.
-