Skip to content

Multiple issues wrt. feature-dependent config expressions #13452

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

Open
brncsk opened this issue Apr 9, 2025 · 0 comments · May be fixed by #13453
Open

Multiple issues wrt. feature-dependent config expressions #13452

brncsk opened this issue Apr 9, 2025 · 0 comments · May be fixed by #13453

Comments

@brncsk
Copy link
Contributor

brncsk commented Apr 9, 2025

I'd like to have config properties that are expressions. I'd also like those expressions to be able to use feature properties, like so:

{
  "schema": {
    "room-color": {
      "type": "color",
      "default": ["case", ["==", ["get", "room-type"], "administrative"], "red", "blue"]
    }
  },
  "layers": [
    "id": "rooms-fill",
    "type": "fill",
    "paint": {
      "fill-color": ["config", "room-color"]
    }
  ]
}

This is only partly supported ATM, because of (at least) two issues I bumped into while stepping through the evaluation code path in one of the workers:

  1. The expression assigned to fill-color above is considered feature constant, and so feature data is not loaded during evaluation. This can be hacked around by wrapping the whole thing into e.g. a let with a get – but this is suboptimal (think ["let", "_" ["get", "room-type"], ["config", "room-color"]]).

  2. Evaluating a match expression in the worker fails and defaults to the "otherwise" branch, if the expression being evaluated is a config expression. This happens here as the typeOf(input) === this.inputType check returns false, probably because the type constants in the worker are not referentially the same as the {kind: ...} value from the unserialized version of the config expression from the main thread(?).

mapbox-gl-js version: 3.11.0

browser: Arc

Link to Demonstration

https://codesandbox.io/p/sandbox/lxfnlg?file=%2Findex.html%3A39%2C20

(If both of these issues are fixed, one of the squares should be red.)

@brncsk brncsk linked a pull request Apr 9, 2025 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant