通过setBoundsBias限制自动完成结果

toh*_*and 5 android google-maps google-places-api

我正在使用setBoundsBias来限制Google地图autocompletePlace中的自动完成结果,但是结果包含超出范围的地方。问题是什么 ?

{

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();
                }

}
Run Code Online (Sandbox Code Playgroud)

xom*_*ena 4

边界偏差不是严格的过滤器,因此不能保证区域之外的地方不被包括在内。目前,Android 版 Places API 没有应用严格限制的选项。

几个月前,Places API Web 服务和 Maps JavaScript API 的地点库中引入了应用严格边界过滤器的功能。您可以在问题跟踪器中参考此功能请求:

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

但是,Android 版 Places API 和 iOS 版 Places API 仍然缺少此功能。

我在 Android 的公共问题跟踪器中创建了一个功能请求:

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

对于 iOS:

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

请为这些功能请求加注星标以添加您的投票并订阅来自 Google 的更新。

希望有一天他们能够实现这一功能。