2017-01-18 15 views

答えて

3

私はこのアプリケーションのソースコードで私の質問に答えを見つけるlink

そして、このようなその表情:

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; 
    } 
+0

これは国名のみを変更します。他のラベルの言語を変更するには? – fdermishin

0

これは私がロシア語のためにそれを行う方法です。次のコードは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)) 
関連する問題