Is it possible to make a label orientation a function of the shape of the polygon it is labeling?

I imagine it's possible with Mapbox GL JS with https://www.mapbox.com/mapbox-gl-style-spec/#layout-symbol-text-rotate, but that seems like it might be a non-trivial JavaScript task (?). The end result will be a Mapbox GL served vector basemap.

Medicine Lake default orientation:

enter image description here

Medicine Lake ideal orientation (but I don't necessarily want any other lake label rotated):

enter image description here

1 Answer 1


This seems non-trivial, but a very cool effect. Roads and contours have dynamic text-rotate, so I'm certain its possible. In Javascript you would need a way to determine the angle of the lake (some centroid method??). Seems like a lot of work.

I've had to do a similar workaround, where I added my own points of interest that required custom text-label properties. This resulted in the POIs as a custom layer so I could adjust the text. I had about 10 POIs that all needed the same formatting.

Clearly, this would be unwieldy for you, as each Lake label would have to be uploaded as its own GeoJson file, then brought into the style as its own layer, just so you could customize the rotation (which you still would need to calculate).


  • Layer that is only the label for Medicine L., then you adjust the text-rotate
  • ... same for each lake.

This is what my solution looked like on Android, custom POIs that were uploaded as .geojson, then styled as their own label in Mapbox Studio.

enter image description here

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.