Limit autocomplete results with setBoundsBias

I use setBoundsBias to limit autocomplete results in google map autocompletePlace, but the result contains places outside the valid range. what is the problem?

{

final int PLACE_AUTOCOMPLETE_REQUEST_CODE = 1;

 AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
                        .setCountry("IR")
                        .build();
                try {
                    Intent intent =
                            new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
                                    .setBoundsBias(new LatLngBounds(new LatLng(38.051183, 46.211586),
                                                new LatLng(38.132784, 46.392860)))
                                    .setFilter(typeFilter)
                                    .build(MainActivity.this);
                    startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE);
                    overridePendingTransition(R.anim.fadein, R.anim.fadeout);

                } catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
                    e.fillInStackTrace();
                }

}
+4
source share
1 answer

Border avoidance is not a strict filter, so there is no guarantee that places outside the area are not included. Currently, the Places API for Android does not have the ability to enforce strict restrictions.

- - Places Maps API JavaScript. :

https://buganizer.corp.google.com/issues/35826806

API- Places Android iOS - .

Android:

https://issuetracker.google.com/issues/38188994

iOS:

https://issuetracker.google.com/issues/38188941

, , Google.

, .

+4

Source: https://habr.com/ru/post/1676651/


All Articles