我试图让纬度经度以下地址,但地理编码器无法找到纬度经度:Geocoder无法从android中的特定字符串获取纬度lng?
卡希纳Palazzetto酒店N.9 - 斯特拉达PROVINCIALE 134,波伊里诺(TO) - 10046,意大利
和我的代码片段如下:
public static LatLng getLocationFromAddress(Context context, String strAddress) {
Geocoder coder = new Geocoder(context);
List<Address> address;
LatLng p1 = null;
try {
address = coder.getFromLocationName(strAddress, 5);
if (address == null) {
return null;
}
Address location = address.get(0);
location.getLatitude();
location.getLongitude();
p1 = new LatLng(location.getLatitude(), location.getLongitude());
} catch (Exception ex) {
Timber.d("getLocationFromAddress(printStackTrace): " + ex);
}
return p1;
}
编辑1:
而且,我试图与设置搜索在地理编码器上与意大利人手动地区设置,但仍然无法获得结果。
没错这就是看起来像REST API的工作,但不知道为什么没有在Android上。 http://maps.google.com/maps/api/geocode/json?address=Cascina%20Palazzetto%20n.9%20-%20Strada%20Provinciale%20134,%20POIRINO%20(TO)%20-% 2010046,%20Italia&sensor = false –
您能提供日志吗? – Cottontree
列表对象地址的大小为0,而我无法从日志中获取任何信息。 –