1

Im trying to offset labels on the border of a polygon to the inside of the polygon in a mapbox-gl style. My data has a series of polygons with shared borders, and the labels on the borders need to be offset in to indicate which polygon is which.

The carto-css equivalent of the effect im looking for is text-placement:line; text-dy:-5;.

I would expect that "symbol-placement": "line", "text-offset": [0,1] in the layout properties would offset the labels in to the polygon, but it offsets the labels down, not inside.

"text-offset": [0,1]

Adding "text-keep-upright": false offsets the labels in the correct direction, but it makes the text upside down on the bottom edge of the polygons.

"text-keep-upright": false

Is there any way to offset the labels in, and keep them upright?

For the sake of completeness, here's a link to my style as it is now https://gist.github.com/JesseCrocker/17e11ccbe12c2b5393032f4585c13cdf

1

I believe using "text-keep-upright": true is the way to go, the fact that that causes the labels to render on the wrong side of the line, I think is a bug see https://github.com/mapbox/mapbox-gl-js/issues/2350

|improve this answer|||||
  • I agree that it seems like the right way to go, but im looking for something that works in practice, not in theory. – Jesse Crocker Apr 12 '17 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.