supercluster
supercluster copied to clipboard
Passing one point does not return any values
I assume since one point cannot be a cluster it just doesn't return it, but this breaks code for me. Could we return the point without a cluster_id or something?
Here is the example and code:
Test Code
POINTS: [
{
"id": "marker-7659",
"lat": "33.65",
"lng": "-86.68",
"address": {
"address": "PO Box 94520",
"city": "Birmingham",
"state": "AL",
"zip": "35220",
"country": "US"
},
"geometry": {
"coordinates": [
"-86.68",
"33.65"
]
}
}
]
BOUNDS: {
"ne": {
"lat": 33.65,
"lng": -86.68
},
"nw": {
"lat": 33.65,
"lng": -86.68
},
"se": {
"lat": 33.65,
"lng": -86.68
},
"sw": {
"lat": 33.65,
"lng": -86.68
}
}
ZOOM: 8
Supercluster code
const clusters = index
.load(points)
.getClusters(
[bounds.sw.lng, bounds.sw.lat, bounds.ne.lng, bounds.ne.lat],
zoom
)
.map(cluster =>
cluster.type === 'Feature'
? {
id: cluster.id,
lat: cluster.geometry.coordinates[1],
lng: cluster.geometry.coordinates[0],
point_count: cluster.properties.point_count,
cluster_id: cluster.properties.cluster_id,
// onclick to get correct zoom
getZoom: () =>
index.getClusterExpansionZoom(cluster.properties.cluster_id)
}
: cluster
)
This just returns and empty array
I have the same issue. getCluster seems to be buggy for fewer points