I am trying to reverse GeoCode a LatLng retrieved from a Marker to get an address. I am easily able to get street address, but the address returned by getFromLocation() never contains a business name (e.g. Tim Hortons). I know that the issue is not with the coordinates because when I return the same result in a different part of my code using "getFromLocationName()" instead, I am getting the friendly name. I can see no reason why getFromLocation()'s return should differ like this from getFromLocationName()'s.
Here is the related code:
private String holderAddress;
...
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
getAddress(marker.getPosition());
...
private void getAddress(LatLng latLng){
Geocoder reverseGeo = new Geocoder(this, Locale.getDefault());
Address processAddress = null;
try {
processAddress = reverseGeo.getFromLocation(latLng.latitude,
latLng.longitude, 1).get(0);
}catch(Exception e){
Log.v("Reverse Geocode failed", e.getMessage());
}
if (processAddress != null) {
holderAddress = processAddress.getAddressLine(0);
} else {
holderAddress = "(" + latLng.latitude + "," + latLng.longitude + ")";
}
}
I have tried retrieving multiple results and reading all address lines as well as feature name. It seems "getFromLocation()" is never returning a business name, while "getFromLocationName()" always manages to grab the friendly name.
Any insight into why I am getting this result or suggestions for possible workarounds are appreciated.
Thanks.