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

Keep feature.id as cluster_id even when promoteId is set to something else #10094

Open
geirmarius opened this issue Nov 12, 2020 · 3 comments
Open
Labels
bug 🐞 needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else)

Comments

@geirmarius
Copy link

geirmarius commented Nov 12, 2020

Motivation

Currently trying to add a hover effect to my clusters, but setFeatureState cannot target the clusters as they do not have any ID. The reason being my promoteId is set to a custom property from my GeoJSON source.

Design Alternatives

Suggestion 1

Ignore promoteId for cluster features.

Suggestion 2 - follow the spec

The style spec says that you can target individual layers for promoteId, but this is false. Setting promoteId as following does not work:

...
promoteId: {
  'some_layer_id': 'some_prop',
  'cluster_layer_id': 'cluster_id',
},
...

If this was to work as the style spec suggests, it would solve the problem.

Design

As suggestion 2 is already following the spec, I assume that would be the most correct way of implementing it, but I don't see any drawbacks with suggestion 1.
Suggestion 1 has the advantage of working without having to specify layer source ids - this can be especially painful if you have a lot of layers you need to target.

Mock-Up

It will not make any changes, except following the spec if that suggestion is chosen.

Concepts

Should add a note in the spec that clusters will use cluster_id instead of promoteId, if suggestion 1 is accepted.

Implementation

I do not have enough knowledge of the mapbox internals to answer this 😅


End notes

Thanks for taking the time to read my suggestion. If there already is a solution to my problem, I've not found it and would love to be pointed in the right direction. Even so the spec do tell me something that is not true, so I believe this will need to be solved either way. In any case, thanks again, and if my issue has problems, or I misunderstood some of the headers, please correct me! 😁

@geirmarius geirmarius changed the title Keep feature.id as cluster_id even with promoteId is set to something else Keep feature.id as cluster_id even when promoteId is set to something else Nov 12, 2020
@mourner mourner added bug 🐞 needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else) labels Nov 12, 2020
@palhal
Copy link

palhal commented Jan 28, 2023

I'm also having this problem. Would love to see this fixed. I created a live demo here: https://jsfiddle.net/pkhalle/cjxz0kdb/

@demiurg
Copy link

demiurg commented Jun 21, 2023

also a problem

@popkinj
Copy link

popkinj commented Oct 25, 2024

I just submitted a draft PR for this. maplibre/maplibre-gl-js#4899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 needs investigation 🔍 Issues that require further research (e.g. it's not clear whether it's GL JS or something else)
Projects
None yet
Development

No branches or pull requests

5 participants