2
votes

I'm using the GoogleApiClient and Places API through Places.GeoDataApi.getAutocompletePredictions() to get address/place autocomplete suggestions (https://developers.google.com/places/android/autocomplete). The method requires a GoogleApiClient object, a String to autocomplete, and a LatLngBounds object to limit the search range. This is what my usage looks like:

PendingResult<AutocompletePredictionBuffer> results =
    Places.GeoDataApi.getAutocompletePredictions(googleApiClient, constraint.toString(), bounds, filter);

According to the documentation, the bounds parameter is required. But when I look at the webservice version (https://developers.google.com/places/webservice/autocomplete#location_biasing) I see a lot more parameters that can be used including location and radius for location biasing.

Is it possible to do the same thing for getAutocompletePredictions() method or do I have to write my own code to hit the webservice, supply the api key, and parse the response? Using GeoDataApi seems convenient because it handles a lot of those details, but I haven't been able to find a good way to easily limit its search range in a smart way. Seems like this be a fairly common scenario, so there must be some widely accepted pattern or solution for this that I just haven't been able to find yet.

1

1 Answers

1
votes

GeoDataApi does seem to be a bit limited at the moment. If you choose to go outside of Google Play Services, you could take a look at the Sprockets for Android library (I'm the developer), which provides a complete Java interface for the Google Places API (see Sprockets for Java). Sprockets also includes a GooglePlaceAutoComplete widget, GooglePlacesLoader, and a GooglePlacesAdapter, in case those might be useful for you.