googlemaps / googlemaps/js-markerclusterer

SuperClusterViewportAlgorithm at zoom 0-3 not working.

Open
#873 2 comments 3 reactions 0 assignees View on GitHub
triage me type: bug
Dominant language
TypeScript
Stars
293
Forks
104
Avg merge
3m
Merged PRs (30d)
18

Description

It does not seem to render starting at zoom 4. But I need zoom 3 for the world view.
Does it somehow ignore/filter out or not get viewport at these zoom levels?

`new SuperClusterViewportAlgorithm({radius: 150, maxZoom: 16, viewportPadding: 50, minZoom: 3, minPoints: 5})`

It looks like the bounds are broken at zoom 3?
I resorted to temporary hack, but I assume something is not correct in the getPaddedViewport math:

```
class NewSuperClusterViewportAlgorithm extends SuperClusterViewportAlgorithm {
public cluster({ map, mapCanvasProjection }: AlgorithmInput): Cluster[] {
let state: SuperClusterViewportState;

if (map.getZoom() <= 3) {
state = {
zoom: Math.round(map.getZoom()),
view: [-180, -90, 180, 90]
};
} else {
state = {
zoom: Math.round(map.getZoom()),
view: getPaddedViewport(
map.getBounds(),
mapCanvasProjection,
this.viewportPadding
),
};
}

return this.superCluster
.getClusters(state.view, state.zoom)
.map((feature: ClusterFeature<{ marker: any }>) =>
this.transformCluster(feature)
);
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.