Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/algorithms/supercluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ export class SuperClusterAlgorithm extends AbstractAlgorithm {
const position = MarkerUtils.getPosition(marker);
const coordinates = [position.lng(), position.lat()];
return {
type: "Feature" as const,
geometry: {
type: "Point" as const,
coordinates,
},
type: "Feature",
geometry: { type: "Point", coordinates },
properties: { marker },
};
} as const;
});
this.superCluster.load(points);
}
Expand All @@ -87,6 +84,13 @@ export class SuperClusterAlgorithm extends AbstractAlgorithm {

this.state = state;

// when input is empty, return right away
if (input.markers.length === 0) {
this.clusters = [];

return { clusters: this.clusters, changed };
}

if (changed) {
this.clusters = this.cluster(input);
}
Expand Down
Loading