mapbox / mapbox/mapbox-gl-js

Fix feature-state dependent styles for *-pattern properties

Open
#7,207 12 comments 4 reactions 1 assignee View on GitHub

@ryanhamley is already working on this.

Since Jan 4, 2021.

bug :lady_beetle: needs discussion :speech_balloon:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.