I want to perform a search by entering user text using the GeoCoder class from Android. Here is my code:
Geocoder iGeocoder = new Geocoder(getContext(), Locale.GERMAN);
public Address getAdress(String aUserInput) {
List<Address> tAddressList = iGeocoder.getFromLocationName(aUserInput, 1000, 47.060940, 8.564278, 51.526396, 13.736392);
if(tAddressList != null &&
tAddressList.size() > 0) {
for(Address tAddress : tAddressList) {
Log.e(TAG, "returning Adress: " + tAddress );
if(tAddress.getCountryCode().equals("DE")) {
return tAddress;
}
}
return null;
} else {
return null;
}
}
The restrictive box that I pass in getFromLocationNameroughly represents the German state of Bavaria. I know that this bounding box does not guarantee that the resulting address really exists. I found some problems, especially when searching by zip code.
- Some of the resulting addresses returned when searching by zip code do not have an "admin zone", so I cannot filter for my desired state (= "Bavaria").
- , 97070, 97078 97076, GeoCoder , . . . 97082 , 97070 ( ) , .