-
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
Fix behaviour when using keep-text-upright in combination with text-offset places text #2350
Comments
Also applies to polygons where you want to keep labels either inside or out side the polygon. Here is a minimal test case. http://jsbin.com/lowekid/1/edit?html,output http://jsbin.com/danexuj/1/edit?html,output |
this also affects gl-native (confirmed via raster tiles api) so tagging as cross-platform. |
I agree that it makes sense for |
Yeah makes sense to me. |
@ansis yeah, it's definitely not totally clear cut. The style spec documentation for text-offset says:
Now, this doesn't speak to the I'm inclined to call this a bug fix rather than a breaking change, because of the above and because it seems somewhat unlikely that many/any users would be relying upon the weirdly inconsistent broken behavior that would be changed here. |
My hunch is it's a breaking change, but I haven't taken the time to layout all possible scenarios. I can think of cases where you always want the label above or below the line regardless of direction of the line, and convesley other times when you want it on the right or left of the line. There are also cases where you want the labels upright and othertimes to left as is. https://jsbin.com/nihogoxope/edit?html,output I'm sure there are use cases where instead of text your label is something like ">>>" to indicate direction, or even a icon font symbol. |
I think I'm comfortable calling this a bug fix. It wasn't intended that cc @mapbox/cartography-cats for further visibility about the key use case that's affected:
Anyone know of concrete cases where removing the unintended ability of
Those cases would be using |
Yes, that's a meta-bug in my original report - the arrows indicating direction are part of the label text, but there's no way to make the text upright without ending up with half the arrows pointing a different way. |
Historical note: I'm also comfortable calling this a bug fix or defining undefined behavior. After this change, how will |
@ansis good question. Added an integration test to #4779 that confirms that the fix therein doesn't change this behavior. (And it looks right to me: regardless of whether or not the text-keep-upright flipping is in effect, |
Is |
It's supported, and also behaves as expected. I'll add it to the integration test. |
@ansis and @anandthakker Can you please clarify if the following is a correct (or not) description of text-anchor for text placement on line geometries?
Other than the symbol spacing value, there aren't any knobs available to the end user that would impact 1. |
I'm fairly sure that none of our Mapbox styles at least use this combination of style properties in this way; none of our styles should be affected if this fix/update is implemented. In the abstract, it seems like this would be a potentially useful styling technique but right now I cannot think of any concrete applications. The carto team has tested out offset road labels (which for certain use cases can help improve legibility by not overlapping the labels and the geometries underneath). For this use case, having all the labels offset in the same direction – regardless of direction of traffic, i.e. the direction of the line – seems cleaner and more readable than offsets in the direction of the traffic at high zooms. At low zooms, offsets in the direction of traffic is probably better, so it's a bit of a toss up. However, the current jump in label positions when the orientation of the text flips is very jarring, especially with dense layers like road labels. For that reason, we deemed this styling technique impractical to use in a production style with the current behavior. |
@mb12 yes, that sounds right. You can see this behavior in action in this integration test: https://github.com/mapbox/mapbox-gl-js/pull/4779/files#diff-16c07158e3ff79c74c4f937c9847d9a4 |
GL-JS version: Whatever was in use in Mapbox Studio on 2016-03-21:
I have direction-specific line geometry in some tiles. I want to offset labels to the right of the lines.
If I specify
text-offset: [[0,1]]
, it works, but a bunch of the labels are upside-down (as expected):If I enable "Keep text upright", then the text is upright, but the Y offset is interpreted incorrectly:
The expected behaviour would be for the labels to rotate around their offset anchor until they're "upright". It seems that the rotation to keep upright needs to be done before the label is offset, rather than after.
The text was updated successfully, but these errors were encountered: