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
Add consistent support for variables in styling #15146
Comments
I'd prefer providing variables as a separate constructor option. As a property of the Map it feels a bit out of place. |
I like the idea of having variables on layers as well, as layers are meant to hold the representation information for their data. This could even be merged with the concept of properties using |
I'm coming back to this since we need to resolve this question in order to merge both the Having variables on the map might be the best way forward IMO:
The fact is that |
I like the style expressions because they allow compact serializable of dynamic styling. Removing I agree that variables at the map level would be useful. What about resolving variables both at the layer and map levels? I think that I don't think we need to be able to set variables individually (because contrary to properties there is no listeners that would be triggered). |
Thinking about how this could be used in the future in To define variables on the map, we could expose constructor options and/or methods that set the variables on the map's top-level layer group. The key benefit of this css-like approach would be that layers could still override variables that are defined on the map's root layer group). |
The
WebGLTile
andWebGLPoints
layers accept avariables
property in thestyle
object passed to the constructor.Then to update those variables, the
updateStyleVariables
method can be called:Although the parser supports
var
expressions, the canvas vector layer doesn't currently acceptvariables
for styling (see #14780 (comment)). We could try to accept avaraibles
as an additional property in a flat style literal, but this would be awkward for arrays of flat styles or rules.It would be more straightforward to add a
variables
orstyleVariables
option to the constructor (instead of trying to tuck it in thestyle
object(s) we accept).If we do this, we could also add support for a top level
variables
option for the WebGLPoints and WebGLTile layers and could deprecate thevariables
property inside thestyle
object. And then we could have consistency in the constructors and in anupdateStyleVariables
method.But it is also probably worth considering allowing style variables at the map level. This would make it so variables related to styling to could be provided and updated in one place. In cases where the same variable is used across multiple layers, this would make it so you don't have to call
layer.updateStyleVariables()
on each layer individually.I know
variables
is a pretty general name. Could also bestyleVariables
(although that is kind of clunky).Curious to hear what others think.
The text was updated successfully, but these errors were encountered: