Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

android - Restrict autocomplete results by setBoundsBias

I am using setBoundsBias for Restrict autocomplete results in google map autocompletePlace, But the result contains places out of 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();
                }

}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The bounds bias is not a strict filter, so there is no guarantee that places outside of the area are not included. Currently the Places API for Android doesn't have an option to apply strict bounds.

A couple of months ago the ability to apply the strict bounds filter was introduced in Places API web service and in places library of Maps JavaScript API. You can refer to this feature request in the issue tracker:

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

However, the Places API for Android and Places API for iOS are still missing this feature.

I have created a feature request in the public issue tracker for Android:

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

and for iOS:

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

Please star these feature requests to add your vote and subscribe to updates from Google.

Hopefully, one day they will implement this feature.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...