Skip to content
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

getChildren method for getting children of a cluster on the next zoom #31

Merged
merged 1 commit into from
Dec 16, 2016

Conversation

mourner
Copy link
Member

@mourner mourner commented Dec 14, 2016

Fixes #13. This is a fast approach replacing changes proposed in #27 and #30. Also addresses mapbox/mapbox-gl-js#3318.

It pretty much doesn't affect performance while allowing to accurately fetch "children" clusters, either for spiderfying, generating a hull, precise "zoom to cluster" or any other features.

The way it works is storing the index of the "origin" point the cluster was created from as its id, and also storing parentId for each point/cluster that was clustered. Then you can fetch the "origin" point, do a radius query around it on the next zoom and filter out points that are not related to the cluster. This operation is almost instant since it's O(log N).

Let me know what you think!

cc @apkoponen @bewithjonam @stepankuzmin

@stepankuzmin
Copy link

Great! I think this is awesome!

@bewithjonam
Copy link

Looks fantastic. Thank you.

Right now,
throws error when you give a wrong clusterId (while retrieveing origin.x/origin.y)
throws error when you give a zoom level that doesn't have a tree. (not sure, should we use _limitZoom or throw a better error)

Fyi, trying to use this with a mapbox-gl-js fork

@mourner
Copy link
Member Author

mourner commented Dec 15, 2016

Thanks for the feedback! I should probably add some descriptive errors. Not sure about _limitZoom — if you change the input zoom, the cluster id relations will probably break.

@apkoponen
Copy link

Awesome, great work! Looking forward seeing this in Mapbox GL JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants