Android Geocoder - different results when called from different geographical locations

不问归期 提交于 2019-12-07 12:46:17

问题


I have the following code in my Android program

List<Address> addressList = geoCoder.getFromLocation(37.790551,-122.433931, 1);
if (!addressList.isEmpty()) {
            address = addressList.get(0);
            String number = address.getSubThoroughfare();
            String streetName = address.getThoroughfare();
.....
}

This is a request to essentially get a street name (hence the 1) from a latitude and longitude in San Francisco.

When I execute this program on a phone in Europe (specifically Ireland) number is returned as 2250-2290 and streetname is returned as Fillmore St.

When I get a friend to run the same code on his phone in California number is null and streetname is still Fillmore st.

I've seen other SO questions allude to region settings but is this possible that the geographical location can affect the query in the Android API?

The Javascript Geocoding API mentions region bias. I wonder is it possible to do something similar in the Android API. I did try creating the Geocoder as

Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.US);

but this does not re-recreate the California based result.


回答1:


From getting people to run identical code on different continents it seems that location is indeed a factor. The Javascript geocoding allows you to specify a region though




回答2:


Are the phones running different versions of android? Also, another thing to keep in mind is that "The Geocoder class requires a backend service that is not included in the core android framework." So, if the two phones are calling upon different backend services to query for the Geocoder, that may explain the output you are seeing.

I think with Android 1.5, they included a Google API backend service implementation for Geocoder. I don't know if newer versions of Android and the Google API made changes to the Geocoder implementation that may be giving you different results or it's coming from some other backend service.



来源:https://stackoverflow.com/questions/5559889/android-geocoder-different-results-when-called-from-different-geographical-loc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!