Place Autocomplete

The autocomplete service in the Google Places API for Android returns place predictions in response to a text-based location search query. The request includes a textual search string and optional filter criteria. You can use this service to provide autocomplete functionality as the user types, by returning places such as businesses, addresses and points of interest.

  1. Usage limits
  2. Get place predictions
  3. Display attributions in your app

Usage limits

Use of the GeoDataApi.getAutocompletePredictions() method is subject to tiered query limits. See the documentation on usage limits.

Get place predictions

To get a list of predicted place names and/or addresses, call GeoDataApi.getAutocompletePredictions(), passing the following parameters:

  • Required: A query string containing the text typed by the user.
  • Optional: A LatLngBounds object, biasing the results to a specific area specified by latitude and longitude bounds.
  • Optional: An AutocompleteFilter containing a set of place types, which you can use to restrict the results to one or more types of place. The following place types are supported in the filter:
    • geocode – Returns only geocoding results, rather than businesses. Generally, you use this request to disambiguate results where the location specified may be indeterminate.
    • address – Returns only autocomplete results with a precise address. Generally, you use this request when you know the user will be looking for a fully specified address.
    • establishment – Returns only places that are businesses.
    • For information about place types in general, see the guide to place types.

The example below shows a simplified call to GeoDataApi.getAutocompletePredictions(). For a complete example, see the sample apps.

PendingResult result =
    Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
        mBounds, mAutocompleteFilter);

The API returns an AutocompletePredictionBuffer in a PendingResult. The AutocompletePredictionBuffer contains a list of AutocompletePrediction objects representing predicted places. The buffer may be empty, if there is no known place corresponding to the query and the filter criteria.

For each predicted place, you can call the following methods to retrieve place details:

  • getDescription() – Returns the description of the place.
  • getMatchedSubstrings() – Returns a list of the substrings from the query that match this place. You can use these substrings to highlight the matching text in the user's query, for example.
  • getPlaceId() – Returns the place ID of the predicted place. A place ID is a textual identifier that uniquely identifies a place. For more information about place IDs, see the place ID overview.
  • getPlaceTypes() – Returns the list of place types associated with this place.

Display attributions in your app

If your app uses the autocomplete service, you must display a 'Powered by Google' attribution. If you retrieve and display additional place information after getting a place by ID, you must display third-party attributions too. See the documentation on attributions.

Send feedback about...

Google Places API for Android