I am designing a map in Mapbox Studio, using mapbox.mapbox-terrain-v2
’s contour
layer to determine the contour lines. This is based on the outdoors style.
In the outdoors style, the contour labels are oriented so that the text is displayed between -90° and 90° of horizontal, because Keep Text Upright is set. If I disable this, then the text becomes oriented at any angle. However, this text is oriented at exactly the opposite angle to what I would like: it always points downhill, not uphill. See first image below: note that the numbers are upright where the elevation increases from north to south.
What I am aiming for is to use the Ordnance Survey style of orienting numbers uphill (upright where the elevation increases from south to north), as in the second image below.
My current style can be seen here. I have tried using the text-rotate
field, but this rotates each character individually, and there does not appear to be a function to reverse the string to counteract this. Additionally, this rotates about the top of each letter, meaning that the result is offset from the actual contour line, and text-translate
+ text-translate-anchor
seem unable to resolve this.
As you noticed, using
text-rotate
on asymbol
layer withplacement: line
rotates each character individually. So you would need to then reverse the string, which isn't possible within the expressions available.However. There is one hacky workaround which may solve the problem for you. You can simply hardcode all the possible elevations with their reversals:
Combined with a
text-offset
of0,1.5
, this actually looks alright:I've published the style here