-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set the map language #63
Comments
I'm trying to work this out too. From the documentation it looks as if the setLanguage function takes in a style and a new language, and returns the style modified to be in the new language. I saw someone else's code which does the following: I tried splitting it out to look at the input style and output style, and it did indeed change the values from I wish the documentation was clear on how this is supposed to work. I don't know what the examples are supposed to do, and I'm not sure why it needs the |
It turns out that the only thing I was missing is to set the language of the map. My theory of how it works is that you alter the styles so that it knows that there is a language lookup for the new language, then you tell the map to use that language. For clarity, here is my code (where this.map.setStyle(this.mapboxlanguage.setLanguage(this.map.getStyle(), newLanguage.code))
this.map.language = newLanguage.code Hope this helps out. Perhaps the documentation could explain this better. |
I don’t see how setting I was only able to work around this issue by turning off style diffing (which has the downside of a jarring flash as the old style gets wiped away completely): map.setStyle(newStyle, { diff: false }); |
My website supports two languages: en, de. The currently selected language is set in the
<html lang>
attribute. The user may choose the language they want out of these two. The map should follow that as well.Without this plugin, my maps are always in German, no matter what I do.
With this plugin, the map follows the browser's first language (if supported, see #4) but not the page content's language from the above attribute.
I saw that there is a
setLanguage
method but it requires a parameterstyle
which is not documented. I have no idea what I should pass to it. So I cannot consider that method. And then there's nothing left. The plugin cannot set the map language to the page language.The text was updated successfully, but these errors were encountered: