-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: get zoom level where a point gets unclustered #205
base: main
Are you sure you want to change the base?
Changes from all commits
8476d83
b825ae1
033a66c
bd821fd
94ed77d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -191,6 +191,28 @@ export default class Supercluster { | |||||
return expansionZoom; | ||||||
} | ||||||
|
||||||
getPointUnclusterZoom(point) { | ||||||
const [lng, lat] = point; | ||||||
const pointX = fround(lngX(lng)); | ||||||
const pointY = fround(latY(lat)); | ||||||
|
||||||
let expansionZoom = this.options.minZoom; | ||||||
while (expansionZoom < this.options.maxZoom) { | ||||||
const tree = this.trees[expansionZoom]; | ||||||
|
||||||
const pointIdxs = tree.within(pointX, pointY, 0); | ||||||
|
||||||
const unclustered = pointIdxs.some( | ||||||
idx => tree.data[idx].parentId !== -1 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks wrong —
Suggested change
But even that, this doesn't look right, because |
||||||
); | ||||||
if (unclustered) return expansionZoom; | ||||||
|
||||||
expansionZoom++; | ||||||
} | ||||||
|
||||||
return expansionZoom; | ||||||
} | ||||||
|
||||||
_appendLeaves(result, clusterId, limit, offset, skipped) { | ||||||
const children = this.getChildren(clusterId); | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since points are more likely to get clustered on higher zooms, it would likely be faster to iterate starting from
maxZoom
and up until there are no points in the location or are all clusters.