Skip to content

Add option for including subPoints for clusters - #27

Closed
apkoponen wants to merge 1 commit into
mapbox:masterfrom
apkoponen:feature-sub-points
Closed

apkoponen wants to merge 1 commit into
mapbox:masterfrom
apkoponen:feature-sub-points

Conversation

@apkoponen

Copy link
Copy Markdown

I'm using supercluster with the Mapbox GL JS library. The biggest shortcoming with the supercluster clustering for good UX has been the lack of ability to reliably zoom in to the clusters. Using a fixed zoom bigger than +1 is bound to cause issues, where some of the points/clusters in the original cluster that was clicked are no longer visible.

This PR adds a includeSubPoints flag, which if turned on, includes all the coordinates of the points belonging to a cluster to the cluster's subPoints property. With the property it is easy then to calculate the proper bounding box for each cluster when they are clicked and visualize the bounds of the cluster similar to Leaflet.markercluster.

I ran some manual tests with my laptop (Macbook Pro 2.5 GHz Intel Core i7, 16 GB RAM with Google Chrome Version 53.0.2785.143 (64-bit). I used the earthquakes.geojson file found in this example with the Leaflet.js example shipped with supercluster. With the includeSubPoints flag on the cluster creation time increased about 20%, from ~50ms to ~60ms. The heap size increased from ~14.5 mb to ~15 mb.

@Exilz

Exilz commented Dec 9, 2016

Copy link
Copy Markdown

This works like a charm, I'd love to this this PR merged.

@mourner

mourner commented Dec 14, 2016

Copy link
Copy Markdown
Member

Thanks for the PR! I'd like to experiment with a different approach to be able to keep the performance while having this ability at all times (not behind an option). The idea is to save the parent id, and then range-search by bbox while filtering by id (instead of keeping arrays in each cluster, which kills performance). This should be relatively fast.

@mourner

mourner commented Dec 14, 2016

Copy link
Copy Markdown
Member

Done! Please check out #31

@mourner mourner closed this Dec 14, 2016
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