[go: nahoru, domu]

Skip to content

Commit

Permalink
fix: Respect setMinClusterSize() correctly when clustering (#759)
Browse files Browse the repository at this point in the history
Previously, when `setMinClusterSize(4)` was called, clusters of size 4 would still be rendered as individual markers instead of clusters (only clusters of size 5 or more would be rendered as individual cluster markers).

With this change, now `setMinClusterSize(4)` will result in clusters of size 4 being rendered as clusters instead of individual markers.

Closes #696
  • Loading branch information
barbeau committed Jun 26, 2020
1 parent 8fe5748 commit 8f30d5f
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,28 @@ protected int getBucket(@NonNull Cluster<T> cluster) {
return BUCKETS[BUCKETS.length - 1];
}

/**
* Gets the minimum cluster size used to render clusters. For example, if "4" is returned,
* then for any clusters of size 3 or less the items will be rendered as individual markers
* instead of as a single cluster marker.
*
* @return the minimum cluster size used to render clusters. For example, if "4" is returned,
* then for any clusters of size 3 or less the items will be rendered as individual markers
* instead of as a single cluster marker.
*/
public int getMinClusterSize() {
return mMinClusterSize;
}

/**
* Sets the minimum cluster size used to render clusters. For example, if "4" is provided,
* then for any clusters of size 3 or less the items will be rendered as individual markers
* instead of as a single cluster marker.
*
* @param minClusterSize the minimum cluster size used to render clusters. For example, if "4"
* is provided, then for any clusters of size 3 or less the items will be
* rendered as individual markers instead of as a single cluster marker.
*/
public void setMinClusterSize(int minClusterSize) {
mMinClusterSize = minClusterSize;
}
Expand Down Expand Up @@ -328,9 +346,12 @@ public void queue(Set<? extends Cluster<T>> clusters) {

/**
* Determine whether the cluster should be rendered as individual markers or a cluster.
* @param cluster cluster to examine for rendering
* @return true if the provided cluster should be rendered as a single marker on the map, false
* if the items within this cluster should be rendered as individual markers instead.
*/
protected boolean shouldRenderAsCluster(@NonNull Cluster<T> cluster) {
return cluster.getSize() > mMinClusterSize;
return cluster.getSize() >= mMinClusterSize;
}

/**
Expand Down

0 comments on commit 8f30d5f

Please sign in to comment.