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

How to show different types of features without creating a new Style? #796

Closed
AlbertoNoris opened this issue Nov 30, 2021 · 3 comments · Fixed by #997
Closed

How to show different types of features without creating a new Style? #796

AlbertoNoris opened this issue Nov 30, 2021 · 3 comments · Fixed by #997
Labels
question Further information is requested stale

Comments

@AlbertoNoris
Copy link

Hi everyone,
I'm working on an app that shows different categories of features:
(in this picture there are multiple features that belong to the categories G and P)
image
I've created a custom Style and everything's working fine but now I want to add a button that makes me able to show only one category or the other (or both) as if I'm Filtering the Data of the Layer from the MapBox Studio:
image
Following the example it looks like i need to create a new Style in MapBox Studio and switch beetwen the two but the problem is that I have 30+ categories, which i would also like to combine (G + P + C or G + C or P + C ...) this would require building hundreds of styles for every combination ... which is far from ideal.

So my question is:
Is there a way to change the features shown in a layer whitout creating Styles for every category of feature I need to show?

Thanks in advance!
If I can provide more info just let me know.

@felix-ht
Copy link
Collaborator

felix-ht commented Nov 30, 2021

You can do this right now, but its not super nice:

1. add the layers as components to the style in mapbox studio
2. add the vector layers to the source(s) added in (1) example

(Note that i have not tested this so there might be some issues that i am not aware of)

If you wait for #797 you would be able to add the vector sources on the fly as well.

This wont work because the layers currently don't support filtering. Implementing this is not super hard but someone has to do it. (might be me as i need this as well - but i can give you no timeline)

@felix-ht felix-ht added the question Further information is requested label Nov 30, 2021
@AlbertoNoris
Copy link
Author

AlbertoNoris commented Dec 1, 2021

Thanks!! I would love to help (as I really needs this feature) but unfortunately I'm not in the position of helping right know (I really don't know what I'm doing).

In the meantime i discovered that i can at least remove a layer.

For example if I wanted to remove the layer ztl-bergamo
Inked144089280-e1d26f99-45e2-450e-ab47-14e68d71c7d7_LI
I just needs to do
mapController?.removeLayer("ztl-bergamo");

This would actually be very usefull if it wasn't that it seems like there's no way of putting it back ...

I'll follow your work!

@stale
Copy link

stale bot commented Jan 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 30, 2022
@stale stale bot closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants