Change language of Google maps on Android

1

I use the Google-maps object to show maps, my apps have the option to change the language of the app, what I can not find is how to make the google-maps view the names of the cities etc. appear in the specified language.

It seems that by default it gets the language set in the phone. How can you define the Locale of the google map?

    
asked by Webserveis 05.09.2017 в 22:37
source

2 answers

0

You can change the language using the Locale .

object

For example, if you use an Activity:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String idioma = "es_ES";
    Locale locale = new Locale(idioma);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
        getBaseContext().getResources().getDisplayMetrics());

    setContentView(R.layout.activity_maps);
}
    
answered by 05.09.2017 в 22:42
0

If you use a Fragment you can define the locale in the method where you initialize the map:

  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        String language= "ru"; //idioma Ruso.
        Locale locale = new Locale(language);
        Locale.setDefault(locale);
        Configuration config = new Configuration();
        if(Build.VERSION.SDK_INT>Build.VERSION_CODES.JELLY_BEAN){
           config.setLocale(locale);
           getContext().createConfigurationContext(config);
        }else { //Obsoleto
           config.locale = locale;
           getResources().updateConfiguration(config, getResources().getDisplayMetrics());
        }

...
...

...

It is important to note that the descriptions on the map do not support all languages, this is an example in Russian language:

the codes can be obtained from: link

    
answered by 05.09.2017 в 23:08