这是我的代码示例,并显示地址、城市等。我希望这对你有所帮助..
try {
List<Address> addresses;
Geocoder geocoder= new Geocoder(MyactivityName.this);
addresses = geocoder.getFromLocation(Marker.getPosition().latitude,Marker.getPosition().longitude,1);
if(addresses != null && addresses.size() > 0 ){
Address address = addresses.get(0);
String province = addresses.get(0).getAdminArea();
Marker.setSnippet(address.getThoroughfare()+", "+province);
}
} catch (IOException e) {
e.printStackTrace();
}
Marker.showInfoWindow();
//get current Street name
String address = addresses.get(0).getAddressLine(0);
//get current province/City
String province = addresses.get(0).getAdminArea();
//get country
String country = addresses.get(0).getCountryName();
//get postal code
String postalCode = addresses.get(0).getPostalCode();
//get place Name
String knownName = addresses.get(0).getFeatureName(); // Only if available else return NULL
System.out.println("Street: " + address + "\n" + "City/Province: " + province + "\nCountry: " + country
+ "\nPostal CODE: " + postalCode + "\n" + "Place Name: " + knownName);
如果您查看更多信息或示例,请查看此链接