Set language in Mapbox Static Image

691 views Asked by At

I am using the Mapbox Static Image API to show users an image of a slice of a map relating to the page they are viewing. Our users are from many countries and expect properly localized country, city names etc.

Question
Is it possible to set the language of all labels in a Mapbox Static Image somehow?

I think I can achieve this by creating a Mapbox Studio Style for each language we want to support, but we have quite a lot of customization in our custom style so I would rather avoid having to manually maintain a version for all supported languages.

I have tried using the playground https://docs.mapbox.com/playground/static/ and also read through the documentation, without finding anything reminiscent of setting the locale

1

There are 1 answers

1
GeppyZ On BEST ANSWER

I think your only option is to create multiple styles for each language you want to support. You probably use a call like this to get your map:

/styles/v1/{username}/{style_id}/static/{overlay}/{lon},{lat},{zoom},{bearing},{pitch}|{auto}/{width}x{height}{@2x}

Use javascript to find your users browser preferred language: How to get the browser language using JavaScript

and change your {style_id} to the requested language.

Another option that comes to mind is to try to use multiple layers. All the background data and (complex) style in one layer, and make a separate layer with your labels. This way you only need to have different styles for your labels and the maintenance will be less of a hassle.