【发布时间】:2019-04-11 08:40:00
【问题描述】:
如何将 Google Places 自动完成 API 搜索区域限制在特定区域?比如我只想搜索墨尔本CBD区域的结果。有没有办法限制这个区域?
【问题讨论】:
-
你可以定义,lat long bound for this
标签: android google-maps google-api
如何将 Google Places 自动完成 API 搜索区域限制在特定区域?比如我只想搜索墨尔本CBD区域的结果。有没有办法限制这个区域?
【问题讨论】:
标签: android google-maps google-api
使用 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();
【讨论】: