google Places API使用getPlacePhotos恢复照片

时间:2015-08-22 14:37:39

标签: android google-places-api photo

我正在尝试从已知的placeID位置(“ChIJqaUj8fBLzEwRZ5UY3sHGz90”)获取照片。

我正在使用以下代码(来自Google指南)

    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();
    }

result.getStatus返回成功,但PhotoMetadataBuffer返回空(photoMetadataBuffer.getCount = 0)。

有没有人使用这种方法成功获得图像?

1 个答案:

答案 0 :(得分:3)

目前看来此地方没有任何相关照片。如果你尝试另一个有相关照片的地方ID,你应该得到一些结果。例如,尝试此地点ID:

ChIJN1t_tDeuEmsRUsoyG83frY4