【问题标题】:Restrict autocomplete results by setBoundsBias通过 setBoundsBias 限制自动完成结果
【发布时间】:2017-05-08 10:56:12
【问题描述】:

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

{

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

}

【问题讨论】:

    标签: android google-maps google-places-api


    【解决方案1】:

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

    几个月前,Places API 网络服务和 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 的更新。

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

    【讨论】:

      猜你喜欢
      • 2018-07-24
      • 1970-01-01
      • 2012-07-16
      • 1970-01-01
      • 2011-05-03
      • 1970-01-01
      • 2011-11-28
      • 2017-10-19
      相关资源
      最近更新 更多