leighhalliday / use-supercluster

A React Hook for using Supercluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How do you create a minPoints option?

hawaiifi opened this issue · comments

So that a cluster isn't created unless there are a minimum number of points.

As an example, I don't want to show a cluster unless it has more than 2 points.

Hey @hawaiifi ! Supercluster itself doesn't have an option for minPoints, but what you might be able to do is something like this:

if (cluster.properties.point_count >= 2) {
  // return marker representing cluster
} else {
  const clusterPoints = supercluster.getChildren(cluster.id);
  return clusterPoints.map(point => <Marker ... />);
}

This way if a cluster has only 2 points in it, you can just grab those points and render them instead.