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

getLeaves returns 'No cluster with the specified id' #72

Closed
KentDi808 opened this issue Jan 9, 2018 · 5 comments
Closed

getLeaves returns 'No cluster with the specified id' #72

KentDi808 opened this issue Jan 9, 2018 · 5 comments

Comments

@KentDi808
Copy link

I am using react-mapbox-gl@3.4.1 and supercluster@3.0.2 to get the list of features in a clicked cluster.

I saw that in V3.0.0 of supercluster the zoom factor is encoded into the cluster_id.

I am using a GeoJSONLayer to do the clustering (which may not be the right way to do it for supercluster) and the correct features are not returned OnClick.

Clicking some clusters throws a run-time error:

'No cluster with the specified id'.

Any idea why no features or the wrong features are being returned?

WebpackBin Showing a working example of the issue.

Any help would be appreciated.

@KentDi808
Copy link
Author

KentDi808 commented Jan 10, 2018

I have come up with a solution that gets me the data that I need.

Modifying the onClick to encode the cluster_id gets all of the items in the cluster.

const cluster_id = (id << 5) + (zoom + 1);

Thanks in advance.

@mourner
Copy link
Member

mourner commented Jan 10, 2018

The Webpack bin isn't loading for me for some reason... I'd guess that you're experiencing this issue because GL JS still uses Supercluster 2.3.0, which doesn't encode zoom into ids. We should upgrade there. Let's close here since it's not directly a supercluster issue.

@mourner mourner closed this as completed Jan 10, 2018
@KentDi808
Copy link
Author

I'm okay with closing it. For some reason if you do a hard refresh the WebpackBin it will render correctly. Also, thanks for the great work you are doing.

@PetengDedet
Copy link

PetengDedet commented Apr 27, 2020

Just get same issue.
After 3 hours of tracing the code, figured out that some of the cluster properties has an empty latitude or longitude. 😅
Filter the data before assign it to the points array. Solved.

Posted here to remind myself or others in the future for easy googling.

@nhk-nguyen
Copy link

Just get same issue.
After 3 hours of tracing the code, figured out that some of the cluster properties has an empty latitude or longitude. 😅
Filter the data before assign it to the points array. Solved.

Posted here to remind myself or others in the future for easy googling.

You're right. Got the same issue and thanks to your comment!

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

No branches or pull requests

4 participants