Fix feature-state dependent styles for *-pattern properties
@ryanhamley is already working on this.
Since Jan 4, 2021.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
per https://github.com/mapbox/mapbox-gl-js/pull/6289#issuecomment-416363685
In the recent addition of data-driven styling support for `*-pattern` properties, `feature-state` dependent expressions do not work. The removal of the `possibleOutputs` state (https://github.com/mapbox/mapbox-gl-js/pull/6289#discussion_r210777581) makes it possible that the icons needed for`feature-state` related paint array updates may not be available in the tile's `ImageAtlas` at update time.
We haven't run into this before because the other data-driven properties that require glyph/icon assets are `layout` properties which don't support `feature-state` expressions yet.
I see a couple options on how to fix this:
- request new images in the `CrossFadedCompositeBinder#updatePaintArrays` method that runs on the main thread when feature states are updated/changed and update the tile's ImageAtlas
- 👎 binder would need access to `ImageManager`, binder would have to send the new ImageAtlas to the tile somehow
- pass available feature-states to the buckets at parse time so the expressions can be evaluated with feature state and all needed images can be requested
- 👎 additional payload on worker thread transfer, doesn't cover the case where no features have the state value that is used in the expression when it is set as a paint property
- reintroduce `possibleOutputs` state and require that `feature-state` dependent expressions for `cross-faded-data-driven` properties be contained as literals
- 👎 lots of special-case logic and behavior, might be confusing/unexpected to users
- not support `feature-state` expressions for `cross-faded-data-driven` properties
- 👎 this is the current behavior, but it fails silently
leaning towards the first option here, but curious if anyone has a different preference or another idea.
cc @asheemmamoowala @jfirebaugh
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.