自动完成后放置标记-Google放置Android API

自动完成后放置标记-Google放置Android API,android,google-maps,autocomplete,google-maps-android-api-2,google-places-api,Android,Google Maps,Autocomplete,Google Maps Android Api 2,Google Places Api,我正在使用Google Places Autocomplete API获取Autocomplete预测结果(作为EditText中的列表): pendingreult结果= Places.GeoDataApi .getAutocompletePredictions(mgoogleAppClient,constraint.toString(), mBounds,mPlaceFilter); AutocompletePredictionBuffer autocompletePredictions=结

我正在使用Google Places Autocomplete API获取Autocomplete预测结果(作为EditText中的列表):

pendingreult结果=
Places.GeoDataApi
.getAutocompletePredictions(mgoogleAppClient,constraint.toString(),
mBounds,mPlaceFilter);
AutocompletePredictionBuffer autocompletePredictions=结果
.等待(60,时间单位秒);
迭代器迭代器=自动完成预测。迭代器();
问题:

我的目标是从用户选择的自动完成结果中添加一个标记

为此,您需要纬度和经度。 自动完成API返回自动完成预测对象的列表但是,自动完成预测没有LatLng字段。

相反,它会给你一个PlaceId——从这里我通过另一个网络调用得到一个Place对象(LatLng):Places.GeoDataApi.getPlaceById


从PlaceId获取Place对象是另一个网络调用,会减慢用户界面的速度。我能以某种方式避免这种情况吗?

我认为您必须执行另一个网络请求才能从位置ID获取位置坐标。即使使用,您仍然必须先获取位置ID列表,然后执行位置详细信息请求才能获取具有位置ID的位置坐标。您可以了解如何执行另一个位置坐标请求,甚至认为它使用的不是
自动完成预测
,而是web服务。
PendingResult<AutocompletePredictionBuffer> results =
           Places.GeoDataApi
           .getAutocompletePredictions(mGoogleApiClient, constraint.toString(),
           mBounds, mPlaceFilter);

AutocompletePredictionBuffer autocompletePredictions = results
                .await(60, TimeUnit.SECONDS);

Iterator<AutocompletePrediction> iterator = autocompletePredictions.iterator();