一个适用于浏览器和 Node 的非常快速的地理空间点聚类库。
一个用于浏览器和 Node 的非常快速的 JavaScript 库,用于地理空间点聚类。
const index = new Supercluster({radius: 40, maxZoom: 16});
index.load(points);
const clusters = index.getClusters([-180, -85, 180, 85], 2);在 Leaflet 中聚类 600 万个点: Supercluster 专为在 Mapbox GL JS 中实现聚类而构建。请在 Mapbox 博客 中阅读有关其工作原理的信息。
使用 NPM(npm install supercluster) 或 Yarn(yarn add supercluster) 安装,然后:
// import as a ES module in Node
import Supercluster from 'supercluster';
// import from a CDN in the browser:
import Supercluster from 'https://esm.run/supercluster';或者在浏览器中使用普通的脚本标签:
<script src="https://unpkg.com/[email protected]/dist/supercluster.min.js"></script>load(points)加载 GeoJSON Feature 对象的数组。每个特征的 geometry 必须是 GeoJSON Point 或 MultiPoint — MultiPoint 以每个坐标为单独点进行聚集,每个点继承特征的 properties 和 id。加载后,索引是不可变的。
getTileRaw(z, x, y)相同的图块,但每个特征都是平面的 - {type: 4, x, y, tags}, 坐标以内联形式显示,而不是包含在嵌套的 geometry 数组中。每个聚集特征都是一个单点,因此
暂无开放 Issues,或尚未同步最近议题。