我正在使用 google autocomplete place api 在我的应用程序中搜索该地点,现在我想获取我搜索过的地点的纬度和经度。如何从android中google的autocomplete place api返回的结果中获取纬度和经度?
以下使用适用于 Android 的 Google 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();
}
});
Visit 适用于 Android 的 Google 地方信息 API https://developers.google.com/places/android/place-details从某个地方检索数据的方法的完整列表
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)