如何使用android sdk更改语言映射框
我需要在android中使用mapbox更改地图语言。我在Office mapbox android应用程序中看到了这一点,但在如何操作的文档中找不到它。我在这个应用程序的源代码中找到了我问题的答案 它看起来是这样的:如何使用android sdk更改语言映射框,android,mapbox,Android,Mapbox,我需要在android中使用mapbox更改地图语言。我在Office mapbox android应用程序中看到了这一点,但在如何操作的文档中找不到它。我在这个应用程序的源代码中找到了我问题的答案 它看起来是这样的: Layer mapText = map.getLayer("country-label-lg"); if (mapText != null) { switch (item.getItemId()) { case R.id.french: mapText.s
Layer mapText = map.getLayer("country-label-lg");
if (mapText != null) {
switch (item.getItemId()) {
case R.id.french:
mapText.setProperties(textField("{name_fr}"));
return true;
case R.id.russian:
mapText.setProperties(textField("{name_ru}"));
return true;
case R.id.german:
mapText.setProperties(textField("{name_de}"));
return true;
case R.id.spanish:
mapText.setProperties(textField("{name_es}"));
return true;
default:
mapText.setProperties(textField("{name_en}"));
return true;
case android.R.id.home:
onBackPressed();
return true;
}
这是我用俄语做的。下一个代码是Kotlin,但您可以将其改编为Java
// Set Russian language if available
val prop_ru = PropertyFactory.textField("{name_ru}")
val idArr = listOf<String>(
"tunnel-oneway-arrows-blue-minor",
"tunnel-oneway-arrows-blue-major",
"tunnel-oneway-arrows-white",
"tunnel-oneway-arrows-white",
"turning-features-outline",
"road-oneway-arrows-blue-minor",
"road-oneway-arrows-blue-major",
"level-crossings",
"road-oneway-arrows-white",
"turning-features",
"bridge-oneway-arrows-blue-minor",
"bridge-oneway-arrows-blue-major",
"bridge-oneway-arrows-white",
"road-label-small",
"road-label-medium",
"road-label-large",
"road-shields-black",
"road-shields-white",
"motorway-junction",
"waterway-label",
"rail-label",
"water-label-sm",
"place-residential",
"airport-label",
"place-islet-archipelago-aboriginal",
"place-neighbourhood",
"place-suburb",
"place-hamlet",
"place-village",
"place-town",
"place-island",
"place-city-sm",
"place-city-md-s",
"place-city-md-n",
"place-city-lg-s",
"place-city-lg-n",
"marine-label-sm-ln",
"marine-label-sm-pt",
"marine-label-md-ln",
"marine-label-md-pt",
"marine-label-lg-ln",
"marine-label-lg-pt",
"state-label-sm",
"state-label-md",
"state-label-lg",
"country-label-sm",
"country-label-md",
"country-label-lg"
)
for (id in idArr)
map.getLayer(id)?.setProperties(prop_ru)
// Set label size for house numbers
map.getLayer("housenum-label")?.setProperties(PropertyFactory.textSize(17f))
这只会更改国家名称。如何更改其他标签的语言?