-
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
Favor previous anchor only when still in the text-variable-anchor
options
#8473
Conversation
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.
This change will make text-variable-anchor
updates deterministic in many cases, but doesn't fully resolve the problem.
Here's an example sequence in Studio where this change will result in a highly deterministic label placement outcome:
["top", "bottom"]
// starting value["top"]
// user deletes bottom["bottom"]
// user adjusts top value to bottom["bottom", "center"]
// user adds a new element (starting value is always center)["bottom", "top"]
// users adjusts center value to top.
And their resulting style would pretty accurately reflect how the style will be rendered after a hard refresh.
Here's another sequence that would result in a less deterministic label placement outcome:
["top", "bottom"]
["top", "bottom", "center"]
// user adds another element["top", "bottom", "top"]
// user changes 3rd element's value totop
["bottom", "top"]
// user deletes the first stop
The property value is the same as in the first example, but the preference for "top" then "bottom" is never cleared.
I see two possible follow-up tasks:
- Prevent duplicate values: Should validator accept same values for an array-enum property? #8370, which would make step (2) from the second example impossible.
- Always clear all preferences whenever
text-variable-anchor
changes via setPaintProperty / setStyle.
That said, I think this PR gets us pretty far and unblocks Studio well enough.
36c1593
to
1791ada
Compare
The de-duplication is also ticketed out in #8445
With #8399 this will require clearing out the preferred placement for multiple properties. |
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.
🚢
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.
LGTM!
Port on gl-native: mapbox/mapbox-gl-native#15129 |
Addresses #8397
The
text-variable-anchor
implementation favored the previous anchor placement for symbols, even if the previous anchor was no longer an option in thetext-variable-anchor
value (when changed bysetStlye
orsetlayoutProperty
)The benchmarks are unaffected because they don't exercise the
text-variable-anchor
property codepath. They use streets-v10 style which predates this property.This PR also needs to be ported to gl-native:
https://github.com/mapbox/mapbox-gl-native/blob/a0e2064f75a229a0bc369ce023e2eaaccb6af074/src/mbgl/text/placement.cpp#L198-L202
@mapbox/studio
and/or@mapbox/maps-design
if this PR includes style spec changes@mapbox/gl-native
if this PR includes shader changes or needs a native portcc @mapbox/studio @mapbox/gl-native @vakila