0
votes

I am new to Google Place API, and I am going through Google reference Guide of place auto-complete

To get prediction for auto complete addresses or places there is a parameter which bounds the map for prediction.

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

I want to know what the most efficient way to do not bound the map so I can run prediction for any part of the world.

For example If I enter Sydney Australia I get predictions from Sydney and If I enter Paris France I get predictions from there!

1
@DanielNugent I don't want to create bounds dynamically based on the current location. My app requirement is to get places locations from all around the world, like I explained in question. - Usman
I thought you meant the device entering the area. In the case that you want the user to select the area through input, you can have a separate input for the user to enter the area to search, and generate the bounds based on the area selected. - Daniel Nugent

1 Answers

3
votes

You can pass in a bounds for the entire world, i.e. a LatLngBounds from (-90, -180) to (90, 180).

Alternatively: just pass in a bounds around the devices location—because the bounds here is just a bias and not a limit. As https://developers.google.com/places/android/autocomplete says [emphasis mine]:

A LatLngBounds object, biasing the results to a specific area specified by latitude and longitude bounds.

So a bounds for Sydney, Australia will still allow the user to autocomplete "Paris, France" just fine!