How to use the supercluster/dist/supercluster function in supercluster

To help you get started, we’ve selected a few supercluster examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / L7 / src / source / transform / cluster.js View on Github external
export function cluster(data, option) {
  const { radius = 80, maxZoom = 18, minZoom = 0, field, zoom = 2 } = option;
  if (data.pointIndex) {
    const clusterPoint = data.pointIndex.getClusters(data.extent, zoom);
    data.dataArray = formatData(clusterPoint);
    return data;
  }
  const pointIndex = new Supercluster({
    radius,
    minZoom,
    maxZoom,
    map: props => ({ sum: props[field] }),
    reduce: (accumulated, props) => { accumulated.sum += props.sum; }
  });
  const geojson = {
    type: 'FeatureCollection'
  };
  geojson.features = data.dataArray.map(item => {
    return {
      type: 'Feature',
      properties: {
        [field]: item[field]
      },
      geometry: {

supercluster

A very fast geospatial point clustering library.

ISC
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis

Popular supercluster functions