我已经创建了返回我当前位置的完整地址的代码,但我希望它只返回我当前位置的某些方面,例如只是邮政编码,只是县等
//Place your latitude and longitude
List<Address> addresses = geocoder.getFromLocation(lati,longi, 1);
if(addresses != null) {
Address fetchedAddress = addresses.get(0);
StringBuilder strAddress = new StringBuilder();
for(int i=0; i<fetchedAddress.getMaxAddressLineIndex(); i++) {
strAddress.append(fetchedAddress.getAddressLine(i)).append("\n");
}
String Address= strAddress.toString();
Toast.makeText(getApplicationContext(),Address, Toast.LENGTH_LONG).show();
这是我到目前为止的代码,所以如果有人能指出我的教程方向或者甚至在这个问题上给我帮助,我将不胜感激
最佳答案
您已经准备就绪。查询地址对象以获取信息:
fetchedAddress.getPostalCode() //zipcode
fetchedAddress.getLocality() //city
参见 http://developer.android.com/reference/android/location/Address.html
关于java - 反向地理编码坐标地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23096595/