Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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: {