I define my boundaries as follows:
private static final LatLngBounds BOUNDS_CHENNAI = new LatLngBounds( new LatLng(12.8339547, 80.0817007), new LatLng(13.2611661, 80.33632279999999));
Create the Goolge API client as follows:
mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this,this) .addApi(Places.GEO_DATA_API) .addConnectionCallbacks(this) .build();
And using these boundaries in the adapter, do the following:
PendingResult<AutocompletePredictionBuffer> results = Places.GeoDataApi .getAutocompletePredictions(mGoogleApiClient, constraint.toString(), mBounds, mPlaceFilter);
According to the documentation, I should only return to me a place in the city of Chennai, but it will return me a place from around the world.
eg. When I type βSolaβ, it returns the βSola roadβ of Ahmedabad instead of showing consistent results within.
android google-places-api
Alok patel
source share