-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Allow overriding SymbolLayer's paint properties using format expression options #8068
Conversation
a98d394
to
760a137
Compare
07e5dae
to
4958eac
Compare
src/data/bucket/symbol_bucket.js
Outdated
this.hasPaintOverrides = SymbolStyleLayer.hasPaintOverrides(layout); | ||
if (this.hasPaintOverrides) { | ||
for (const layer of this.layers) { | ||
layer.setPaintOverrides(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a SymbolStyleLayer can exist either with overrides applied or not. And since the state depends on this method call it is hard to tell elsewhere what the state of the style layer is. Your current implementation looks correct but I think someone less familiar with this could easily make changes that either result in setPaintOverrides()
being called more or less than once, or before recalculate()
.
Would triggering it in styleLayer.recalculate(...)
make sense?
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at this point sections
is set to the sections of a single formatted expression. In the case where there is a ZoomConstantExpression with multiple possible formatted expressions it will only hold the last one. If the last expression has no overrides but an earlier one does, does this return the wrong value?
For example:
["case",
["get", "colourful"], ["format", "red text", { "text-color": "red" }],
["format", "default text", {}]]
|
||
constructor(specification: StylePropertySpecification) { | ||
constructor(specification: StylePropertySpecification, overrides?: Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to make the type of overrides
more specific?
02b9db3
to
a35dd5c
Compare
The previous way of checking for paint overrides didn't properly handle the case where there might be multiple cases with some not having overrides.
This seems more robust because it changes the calculated values consistently after they are calculated instead of just in some cases. This makes it a bit easier to understand what state the style layer is in.
9bd3be4
to
b4386e3
Compare
Port of mapbox/mapbox-gl-native#14062
Launch Checklist