Android地理编码器 - 从不同的地理位置调用不同的结果 [英] Android Geocoder - different results when called from different geographical locations

查看:151
本文介绍了Android地理编码器 - 从不同的地理位置调用不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Android程序中有以下代码:

  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();
.....
}

这实质上是一个请求一个街道名称(因此 1 )来自旧金山的经纬度。



当我执行这个程序时在欧洲的电话(特别是爱尔兰) number 返回为 2250-2290 街道名称返回为 Fillmore St



当我得到朋友运行相同他在加利福尼亚州的电话号码 number null 街道名称仍然是 Fillmore st



我已经看到其他SO问题提及区域设置,但这可能是地理位置可以影响Android API中的查询吗?

Javascript 地理编码API提到区域偏见。我想知道是否有可能在Android API中做类似的事情。我曾尝试将Geocoder创建为

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

但这不会重新创建基于加州的结果。
<解决方案

从让人们在不同的大陆运行相同的代码看起来,位置确实是一个因素。
使用Javascript
地理编码可以指定 region 尽管


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.

解决方案

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

这篇关于Android地理编码器 - 从不同的地理位置调用不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆