You can customize the language and region settings used in your map by changing the default language settings and the map's region code, which can affect the behavior of the map based on the specified country or territory.
See the coverage for Maps 3D SDK for Android in the Maps coverage table.
Language localization
By default, the Maps 3D SDK for Android uses the language settings configured on the user's device to determine which translation of the map to display. However, you can override this default behavior and set a specific language when initializing the map, or update the language and region dynamically after the map is initialized.
Setting the language affects the language that UI controls, tooltips, and copyright notices are displayed in. Runtime locale updates are reflected in the map view, but not any of the other UI controls, tooltips, or other such elements. It also affects the translation of political features, descriptors, and natural features—such as changing "Geneva" to "Genève" or "lake" to "lac"—and changes the direction that text is rendered for right-to-left scripts.
The Maps 3D SDK for Android looks for localization preferences in the following order. If preferences aren't defined at the first step, then it continues looking in the specified order:
- Runtime updates: Language and region preferences passed to
setLocaleon yourGoogleMap3Dinstance usingLocaleOptions. - Map initialization: Language and region preferences specified when
creating the map, either in your layout XML on
Map3DViewusing themap3d:languageandmap3d:regionattributes, or programmatically usingMap3DInitConfig. - Device settings: The system default locale configured on the Android device.
The following example displays a map in Chinese ("zh") and sets the region to
China ("CN").
You can configure the language and region in your layout XML file using the
map3d:language and map3d:region attributes on
Map3DView:
<com.google.android.gms.maps3d.Map3DView
android:id="@+id/map3dView"
android:layout_width="match_parent"
android:layout_height="match_parent"
map3d:mapMode="hybrid"
map3d:language="zh"
map3d:region="CN" />
You can also update the language and region dynamically at runtime by creating a
LocaleOptions
instance, setting the values with
setLanguage
and
setRegion,
and passing it to
setLocale
on your
GoogleMap3D
instance:
val localeOptions = LocaleOptions().apply {
language = "zh"
region = "CN"
}
googleMap3D.setLocale(localeOptions)
Region localization
Setting the region using the map3d:region XML attribute, the
region
property on
Map3DInitConfig,
or
setRegion
on
LocaleOptions
can serve different map tiles or bias the application towards more
regionally appropriate results. Additionally, setting the region tag ensures
that the application complies with local laws by applying the correct regional
localization for the country or territory where the application is distributed.