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

Mapbox Expression using ["format", <TEXT>, {"text-color": "<COLOR>"}] causes toRenderColor error #13340

Open
Dylansc22 opened this issue Dec 2, 2024 · 0 comments

Comments

@Dylansc22
Copy link

Dylansc22 commented Dec 2, 2024

See demo video below of error which occurs in mapbox studio and on my live map app.

The cause of the bug
appears to be the text-filed attribute in mapbox studio, which makes use of the mapbox expression format

The expression 👇

[
  "case",
  [
    "all",
    ["has", "name"],
    ["has", "name_en"],
    [
      "!=",
      ["get", "name"],
      ["get", "name_en"]
    ]
  ],
  [
    "format",
    ["get", "name_en"],
    {
      "font-scale": 1
    },
    "\n",
    ["get", "name"],
    {
      "font-scale": 0.8,
     "text-color": "grey"
    }
  ],
  ["format", ["get", "name"]]
]

The error it causes 👇

Uncaught TypeError: r.toRenderColor is not a function
    at o_._setPaintValue (147.ddd73483.js:8:36290)
    at o_.updatePaintArray (147.ddd73483.js:8:36196)
    at 147.ddd73483.js:8:41263

If I remove the "text-color": "grey" condition from the format statement, the error does not occur.

Screen.Recording.2024-12-02.at.10.28.41.PM.3.mov
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

No branches or pull requests

1 participant