JoelMercurio
JoelMercurio

Reputation: 117

Show Two Letter State Code on Mapbox Instead of out of the box Abbreviation Provided

I would like to show the two letter state code on states in the United States of America in mapbox. I've taken a look at the state-label editor shown here:

mapbox screenshot

The closest option is iso_3166_2 but this prepends all the labels with a US- like US-OH. Is there a way to just have OH? any information would be helpful.

Thanks!

Upvotes: 0

Views: 608

Answers (1)

Sylvester
Sylvester

Reputation: 131

I found out that we can use string operators to modify the string as well. https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/

In your case, slice(coalesce(iso_3166_2), 3, 5) seems to work

enter image description here

Upvotes: 2

Related Questions