0

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.

Demonsoul
  • 791
  • 4
  • 11
  • The inputs of `getFromLocation()` are latitude and longitude, versus the input of `getFromLocationName()` is an address name. So the results are different. – ztan Oct 20 '15 at 17:46

1 Answers1

0

I have concluded that Geocoding is simply not viable for real-time place look-up. While there is a getFeatureName() field, it seems to only return anything useful for precise GPS coordinates so dropping a pin will almost never result in a useful fetaure name.

I have switched to Google Places API instead for business name look-ups, and for consistency's sake, am also now using nearbysearch from Places API for searching instead of Geocoding.

Demonsoul
  • 791
  • 4
  • 11