我爲Android使用Places.GeoDataApi,根據執行請求的設備的位置,我得到不同的搜索結果。我需要結果始終位於邊界內。我沒有看到可以在getAutocompletePredictions請求中設置的位置。有什麼我失蹤?如何在界限內獲取Places.GeoDataApi.getAutocompletePredictions?
我得到使用GoogleApiClient和地點API通過地址/位自動完成建議:
Places.GeoDataApi.getAutocompletePredictions()
該方法需要GoogleApiClient對象,String自動完成,並且對象的LatLngBounds限制搜索範圍。這是我的用法是什麼樣子:
LatLngBounds bounds = new LatLngBounds(new LatLng(38.46572222050097, -107.75668023304138),new LatLng(39.913037779499035, -105.88929176695862));
GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.addApi(Places.GEO_DATA_API)
.build();
PendingResult<AutocompletePredictionBuffer> results =
Places.GeoDataApi.getAutocompletePredictions(googleApiClient, "Starbucks", bounds, null);
使用的版本:com.google.android.gms:播放服務定位:8.3.0
文檔: https://developers.google.com/places/android/autocomplete
案例打開: https://code.google.com/p/gmaps-api-issues/issues/detail?id=10981&thanks=10981&ts=1480591333 –