Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google places autocompletes API Android : bounds not working

I'm defining my bounds as follow:

private static final LatLngBounds BOUNDS_CHENNAI = new LatLngBounds(
        new LatLng(12.8339547, 80.0817007), new LatLng(13.2611661, 80.33632279999999)); // Chennai city bounds.

Creating Goolge API client as follow:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this,this)
            .addApi(Places.GEO_DATA_API)
            .addConnectionCallbacks(this)
            .build();

And using those bounds in adapter as follow:

PendingResult<AutocompletePredictionBuffer> results =
                Places.GeoDataApi
                        .getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
                                mBounds, mPlaceFilter);

According to the documentation is should return me only location within Chennai city, but it returns me location from around the world.

E.g. When I type "Sola" it returns "Sola road" of Ahmedabad city instead of showing matched results within bounds.

like image 317
Alok Patel Avatar asked Oct 30 '15 04:10

Alok Patel


1 Answers

I have the same problem with the bounds in android. I've tried everything and can't solve the problem.

Looking for other web pages, i found this in the documentation for javascript when trying to set bounds to an area:

The results are biased towards, but not restricted to, Places contained within these bounds.

It looks like the android places api documentation is not complete. We will have to wait.

like image 134
user3821381 Avatar answered Oct 01 '22 05:10

user3821381