相关疑难解决方法(0)

如何在边界内获取Places.GeoDataApi.getAutocompletePredictions?

我正在使用Android的Places.GeoDataApi,我会根据执行请求的设备的位置获得不同的搜索结果.我需要将结果始终位于边界内.我没有看到在getAutocompletePredictions请求中可以设置的位置.有什么我想念的吗?

我通过以下方式使用GoogleApiClient和Places API获取地址/地点自动填充建议:

Places.GeoDataApi.getAutocompletePredictions()
Run Code Online (Sandbox Code Playgroud)

该方法需要一个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);
Run Code Online (Sandbox Code Playgroud)

正在使用的版本:com.google.android.gms:play-services-location:8.3.0

文档:https: //developers.google.com/places/android/autocomplete

google-maps google-places-api google-places android-googleapiclient

6
推荐指数
2
解决办法
5980
查看次数