English instead of local language for Geocoder

前端 未结 3 1698
迷失自我
迷失自我 2021-01-05 14:47

I am using Geocoder to get address from lan/lat coordinates. The problem is that the address is in local language (the street name usually). How can I set it to be only in E

相关标签:
3条回答
  • 2021-01-05 15:15

    API 19
    The answer is not completely correct I think.
    I have just had that case, when I set the GeoCoder locale to English then I get wrong street names.
    It does not translate them but it removed language specific parts, that's a concern for me.

    "Straße" became "St" for example.

    The Google Maps HTTP Geocoder API is different in this regard, when I set an english language the streets are returned correctly just the tested country was translated (Austria instead of Österreich).

    As many people use the HTTP API as fallback in case the Geocoder fails this can be a problem, like in my case.
    My solution is to always use the locale of the country for BOTH APIs, then the results match.
    The HTTP API has a &language parameter which understands Local.toString() as value;
    The Geocoder can be initlized like in the original question shown.

    0 讨论(0)
  • 2021-01-05 15:26

    create a new locate instance like this:

        Locale aLocale = new Builder().setLanguage("en").setScript("Latn").setRegion("RS").build();
        Geocoder geocoder = new Geocoder(context,aLocale);
    

    https://developer.android.com/reference/java/util/Locale.Builder.html

    0 讨论(0)
  • 2021-01-05 15:31

    I don't think this is possible. Street names are street names. They don't get translated. You have a name. Your name is your name, no matter what language anybody may speak. You don't "translate" your name when you talk to people in foreign languages.

    A Geocoder is just a database that maps Geocoordinates to other entitities. In general you won't find multiple names for a street. There are a few instances where names are translated (city names, for example, can be translated into multiple languages), but theese are the exception and not the rule.

    0 讨论(0)
提交回复
热议问题