mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.19k stars 2.22k forks source link

Support feature-state in layer filters #8487

Open gampleman opened 5 years ago

gampleman commented 5 years ago

Motivation

We use feature-state for client side data joins. We would like to do some dynamic filtering of the data based on feature-state.

Design Alternatives

We could as a work around set the opacity of these features to 0 conditionally. It does seem a bit hacky though.

Design

I'm not sure about the technicalities, but it seems that feature-state could just be allowed in filter expressions.

Concepts

I don't think there are any new concepts here, just broadening existing features to work together.

Implementation

No idea.

asheemmamoowala commented 5 years ago

Duplicate of https://github.com/mapbox/mapbox-gl-js/issues/6876

Supporting feature-state performantly on layer filters is not possible with the current architecture. Keeping this open as a feature request, but it is not on our roadmap to address currently.

florianPOLARSTEPS commented 2 years ago

Just throwing my use-case and how this feature would help in here.

I have a property called is_selected on my features.

My current solution works as follows

This of course works like a charm, but since I have to update the whole GeoJsonSource (which in turn seems to do a full serialization of the data) in order to change the state of one feature from is_selected=false to is_selected=true it would be really helpful to be able to just update a feature-state and the layer setup will still work as intended. (bringing the selection to the front)

underbluewaters commented 2 years ago

I've got a use case for this. I'd like to create an editor for a layer that is represented using vector tiles. If someone edits a property of a feature, it may effect the color of the rendered polygon. Rather than fetching a whole new set of tiles on form submission, I could duplicate feature properties as feature-state for those that have been edited and have my style layers render based on both the feature-state and regular properties.

mryellow commented 1 week ago

If you can filter based on properties then you should be able to filter based on run-time "properties" (feature-state).

get and feature-state should function the same.