【发布时间】:2011-05-14 11:57:16
【问题描述】:
我正在尝试获取当前位置的街道名称,但似乎无法获取。
我使用这种方法来检索地址:
public Address getAddressForLocation(Context context, Location location) throws IOException {
if (location == null) {
return null;
}
double latitude = location.getLatitude();
double longitude = location.getLongitude();
int maxResults = 1;
Geocoder gc = new Geocoder(context, Locale.getDefault());
List<Address> addresses = gc.getFromLocation(latitude, longitude, maxResults);
if (addresses.size() == 1) {
return addresses.get(0);
} else {
return null;
}
}
然后我可以做类似的事情。 address.getLocality() 和 address.getPostalCode()
但我想要的是街道名称。就像在“Potterstreet 12”中一样。当我打印 AddressLine(0) 和 AddressLine(1) 时,我只得到邮政编码、城市和国家/地区。
如何检索我当前所在位置的街道名称?
【问题讨论】:
标签: android google-maps geolocation