我使用的是Google Places SDK,当我尝试获取选定的位置信息时,我可以获取名称和ID,但无法获取Latlng等
fragments[1].setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
Log.i("asd", "Place: " + place.getLatLng().latitude + ", " + place.getId());
}
@Override
public void onError(Status status) {
// TODO: Handle the error.
Log.i("asd", "An error occurred: " + status);
}
});
}
I/asd: Place: Place{address=null, addressComponents=null, attributions=[], id=ChIJO3svnEReUjoR38xr0NFxtiU, latLng=null, name=Vels University, openingHours=null, phoneNumber=null, photoMetadatas=null, plusCode=null, priceLevel=null, rating=null, types=null, userRatingsTotal=null, viewport=null, websiteUri=null}, ChIJO3svnEReUjoR38xr0NFxtiU
答案 0 :(得分:0)
fragments[1].setPlaceFields(Arrays.asList(Place.Field.ID, Place.Field.LAT_LNG));
我想像上面一样添加Place .field.Lat_LNG属性
按 https://developers.google.com/places/android-sdk/place-details