07 · Clusters
5,000 points indexed by GeoJSONClusterSource, drawn as bubbles with their counts that regroup as you zoom. The index builds a tree per zoom level up front, so getClusters answers in O(log n).
Open it full screen · Edit and run it · Full source: 07-clusters.ts
// radius in on-screen pixels: the map's tiles are 256 px
const source = new GeoJSONClusterSource({ radius: 60, extent: 256, maxZoom: 16 })
source.load(features)
const items = source.getClusters([west, south, east, north], Math.floor(map.getZoom()))