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

Map-wide variables #8404

Closed
stevage opened this issue Jun 28, 2019 · 2 comments
Closed

Map-wide variables #8404

stevage opened this issue Jun 28, 2019 · 2 comments

Comments

@stevage
Copy link
Contributor

stevage commented Jun 28, 2019

Motivation

Expressions can respond to three things (afaik): properties of the data, zoom, and temporary feature state of the data. But sometimes it would be helpful to respond to something map-wide, like a "dark mode" or whether a satellite basemap is present, or whether the user has requested large fonts.

Design Alternatives

Currently, the way to handle this is to call map.setPaintProperty on each specific layer when that map-wide property changes. But that's not ideal, because it often means defining layer properties twice: once as initially shown, and then later when reset:

map.addLayer({ ... "line-color": "dark-green") })
...
on("basemapchange", () => map.setPaintProperty("my-lines", "line-color", "light-green")

Design

Something like:

"line-color": ["case", ["variable", "dark-mode"], "dark-green", "green"]

map.setVariable("dark-mode", true)
@peterqliu
Copy link
Contributor

We used to have style classes, but removed them because they were hard to design for in Studio and the use case was perceived to be obscure. I've found them useful.

@asheemmamoowala
Copy link
Contributor

Duplicate of #7946

@asheemmamoowala asheemmamoowala marked this as a duplicate of #7946 Jul 1, 2019
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

3 participants