谷歌Places API的使用retriving的getPlacePhotos照片 [英] google Places API retriving an photos using getPlacePhotos

查看:863
本文介绍了谷歌Places API的使用retriving的getPlacePhotos照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从已知placeID位置(ChIJqaUj8fBLzEwRZ5UY3sHGz90)中的照片。

I'm trying to get a photo from known placeID location ("ChIJqaUj8fBLzEwRZ5UY3sHGz90").

我使用的是code以下(从谷歌指南)

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

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

the result.getStatus returns a success, but PhotoMetadataBuffer is returned empty (photoMetadataBuffer.getCount = 0).

有没有人用这种方法顺利地拿到了一个形象呢?

Has anyone successfully got an image using this method?

推荐答案

它看起来像有不符合目前这个地方相关的所有照片。如果您尝试有相关照片另一个地方的id,你应该得到的一些结果。例如,尝试这个地方ID:

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

这篇关于谷歌Places API的使用retriving的getPlacePhotos照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆