I am using google-play-service-lib
. How can I change language of google map i.e. show locations in korian language or Hindi Language.
You can change location for Google Maps that use the Google Map API V2 by using a Locale Object. The language needs to be supported on the device being used though.
Here is the full list of supported languages.
With this code below I was able to change the language on the map to Chinese:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languageToLoad = "zh_CN";
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
Result, language set to Chinese in the code (no manual changes) on a U.S. based phone:
I was also able to get it to show Korean, use this Locale code:
String languageToLoad = "ko_KR";
Result:
NOTE
It looks like the supported languages for Google Maps are listed here: https://developers.google.com/maps/faq#languagesupport
setContentView()
, or any other type of layout inflating. –
Millsaps hi_IN
? –
Millsaps We only need to change the location in the application to get the Map´s descriptions with different language. We have to add validations to avoid the use of deprecated methods:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String language= "hi"; //Hindi language!.
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 { //deprecated
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
}
...
...
...
Very important to say that all the languages are not supported, this is an example in Russian language:
We can get the code languages from:
Just change the locale on the device. If translations are available, they will be shown automatically.
A screenshot of my US phone with the locale switched to Korean:
hope this easy solution for changing map language helps someone:
simply add call setUpMapLocale()
in your activity onCreate()
:
private fun setUpMapLocale() {
val languageToLoad = "iw_IL" // your desired language locale
val locale = Locale(languageToLoad)
Locale.setDefault(locale)
baseContext.resources.configuration.setLocale(locale)
}
so i just had to call setLocale()
on the existing configuration attached to baseContext
resources
With new Google Map Render Support now you will get this, Need to follow a few steps,
Update Google Map Dependency
implementation 'com.google.android.gms:play-services-maps:18.1.0'
Create New Class that Extends the Application, and initialize a new Map Renderer.
class MyApplication : Application() { override fun onCreate() { super.onCreate() MapsInitializer.initialize( applicationContext, MapsInitializer.Renderer.LATEST, object : OnMapsSdkInitializedCallback { override fun onMapsSdkInitialized(p0: MapsInitializer.Renderer) { Log.e("MapsInitializer", p0.name) } }) }
}
Register MyApplication class in Manifest.
<application
android:name="com.extra.MyApplication"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
If you think that locale configuration is already correct as mentioned below and you still have the problem.
Locale locale = new Locale("en"); // Exmaple for English
Locale.setDefault(locale);
Resources resources = getResources();
Configuration configuration = resources.getConfiguration();
configuration.setLocale(locale);
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
It is possible that you are using default google maps initializer which uses LEGACY renderer as below:
MapsInitializer.initialize(this);
If you really use it then let test with LATEST renderer instead:
MapsInitializer.initialize(this, MapsInitializer.Renderer.LATEST, null);
I tried and tested with many things, but it works with only with LATEST renderer.
© 2022 - 2025 — McMap. All rights reserved.