问题
I'm trying to get a photo from known placeID location ("ChIJqaUj8fBLzEwRZ5UY3sHGz90").
I'm using the code below (from the google guide)
PlacePhotoMetadataResult result = Places.GeoDataApi.getPlacePhotos(mGoogleApiClient, placeId).await();
if (result.getStatus().isSuccess()) {
PlacePhotoMetadataBuffer photoMetadataBuffer = result.getPhotoMetadata();
if (photoMetadataBuffer.getCount() > 0 && !isCancelled()) {
// Get the first bitmap and its attributions.
PlacePhotoMetadata photo = photoMetadataBuffer.get(0);
CharSequence attribution = photo.getAttributions();
// Load a scaled bitmap for this photo.
Bitmap image = photo.getScaledPhoto(mGoogleApiClient, mWidth, mHeight).await()
.getBitmap();
attributedPhoto = new AttributedPhoto(attribution, image);
}
// Release the PlacePhotoMetadataBuffer.
photoMetadataBuffer.release();
}
the result.getStatus returns a success, but PhotoMetadataBuffer is returned empty (photoMetadataBuffer.getCount = 0).
Has anyone successfully got an image using this method?
回答1:
It looks like there aren't any photos associated with this place at the moment. If you try another place id that has associated photos, you should get some results. For example, try this place id:
ChIJN1t_tDeuEmsRUsoyG83frY4
来源:https://stackoverflow.com/questions/32157317/google-places-api-retriving-an-photos-using-getplacephotos