【问题标题】:How to restrict google auto completion to search only a few neibourghoods in a city?如何限制谷歌自动完成只搜索城市中的几个街区?
【发布时间】:2019-04-11 08:40:00
【问题描述】:

如何将 Google Places 自动完成 API 搜索区域限制在特定区域?比如我只想搜索墨尔本CBD区域的结果。有没有办法限制这个区域?

【问题讨论】:

  • 你可以定义,lat long bound for this

标签: android google-maps google-api


【解决方案1】:

使用 FindAutocompletePredictionsRequest 对象,如下所示,bounds,

RectangularBounds bounds = RectangularBounds.newInstance(
new LatLng(-33.880490, 151.184363),
new LatLng(-33.858754, 151.229596));

FindAutocompletePredictionsRequest request = 
FindAutocompletePredictionsRequest.builder()
// Call either setLocationBias() OR setLocationRestriction().
 .setLocationBias(bounds)
 //.setLocationRestriction(bounds)
 .setCountry("au")
 .setTypeFilter(TypeFilter.REGIONS)
 .build();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-30
    • 2018-12-08
    • 2017-06-14
    • 2017-04-12
    • 2012-01-07
    • 1970-01-01
    • 2018-03-24
    • 2011-05-15
    相关资源
    最近更新 更多