What is @types/supercluster?
@types/supercluster provides TypeScript type definitions for the supercluster library, which is a fast geospatial point clustering library for browsers and Node.js.
What are @types/supercluster's main functionalities?
Creating a Supercluster instance
This feature allows you to create a new Supercluster instance with specific options such as radius and maxZoom.
const supercluster = require('supercluster');
const index = supercluster({
radius: 40,
maxZoom: 16
});
Loading points into the cluster
This feature allows you to load an array of GeoJSON Feature objects into the Supercluster instance.
index.load([{
type: 'Feature',
properties: {},
geometry: {
type: 'Point',
coordinates: [0, 0]
}
}]);
Getting clusters for a specific area and zoom level
This feature allows you to retrieve clusters for a given bounding box and zoom level.
const clusters = index.getClusters([-180, -85, 180, 85], 2);
Getting the children of a cluster
This feature allows you to get the children of a specific cluster by its cluster ID.
const children = index.getChildren(clusterId);
Getting the leaves of a cluster
This feature allows you to get the leaves (original points) of a specific cluster, with optional limit and offset parameters.
const leaves = index.getLeaves(clusterId, limit, offset);
Other packages similar to @types/supercluster
kdbush
kdbush is a fast static spatial index for 2D points based on a flat KD-tree. It is used internally by supercluster for spatial indexing but can be used independently for fast nearest neighbor queries.
rbush
rbush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles. It is similar to supercluster in that it provides fast spatial queries, but it uses an R-tree data structure instead of a KD-tree.
geocluster
geocluster is a simple clustering library for geospatial points. It is less feature-rich compared to supercluster but can be used for basic clustering needs.