fix: supercluster max zoom with fractional zooming #887
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Whether to re-cluster on zoom is determined by the fractional zoom value here:
js-markerclusterer/src/algorithms/supercluster.ts
Line 76 in c5cdf54
however the clusters are calculated using a rounded integer value here:
js-markerclusterer/src/algorithms/supercluster.ts
Line 92 in c5cdf54
This means if our new zoom value is fractionally above our maxZoom, it will be the final re-cluster on zooming in. However the clusters returned will not be de-clustered, as the rounded down value used for
getClusters
is not above our maxZoom, leaving our clusters not in the final de-clustered state even as we continue to zoom in.Fixes #647 🦕
example of existing behaviour from issue 647:
maxZoom=14
zoom map to 14.2
getClusters
called for zoom=14zoom map to 16.2
getClusters
not calledResult: will never decluster as
getClusters
is never called with a value above maxZoomexample of behavior with fix:
maxZoom=14
zoom map to 14.2
getClusters
called for zoom=14zoom map to 16.2
getClusters
called for zoom=16Result: does decluster as
getClusters
is called with a value above maxZoom