gpt4 book ai didi

android - 将 PlaceID 字符串转换为 LatLng 对象

转载 作者:行者123 更新时间:2023-11-29 23:21:58 25 4
gpt4 key购买 nike

我试图将我存储在数据库中的 placeId 字符串转换为 LatLng 坐标,我得到了这样的 id:place.getId() 从一个地方对象,现在当我从我想将其转换回坐标或至少一个 Place 对象的服务器。

谢谢!

最佳答案

声明对象为

GoogleApiClient mGoogleApiClient;

然后初始化为

 mGoogleApiClient =
new GoogleApiClient.Builder(...)
...
.build();

并将其传递给 Places API 的函数。

Places.GeoDataApi.getPlaceById(mGoogleApiClient, placeId)
.setResultCallback(new ResultCallback<PlaceBuffer>() {

@Override
public void onResult(PlaceBuffer places) {
if (places.getStatus().isSuccess()) {
final Place myPlace = places.get(0);
LatLng queriedLocation = myPlace.getLatLng();
Log.v("Latitude is", "" + queriedLocation.latitude);
Log.v("Longitude is", "" + queriedLocation.longitude);
}
places.release();
}
});

并在回调中检索坐标。 (代码从 here 复制)

关于android - 将 PlaceID 字符串转换为 LatLng 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54213872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com