来自Google Places Api的Photo_reference

时间:2012-12-05 09:40:12

标签: google-places-api google-places

我看到google places的json响应会返回一个字段photo_reference。有谁知道如何关联图像?

  "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
         "id" : "320d77fa60610f618058bd58b8ba46e340c615b8",
         "name" : "The Meat & Wine Co",
         "opening_hours" : {
            "open_now" : true
         },
         "photos" : [
            {
               "height" : 968,
               "html_attributions" : [],
               "photo_reference" : "CoQBeQAAAAgOdveT3dRtzoJ42BTBZfCdZptWsqLN3bROkP4FVHNNX-qjxBiw0vdGpDaX_lVb3rcaQf5hBVvrEdMUMDKB2gcsIOaVNII_zLvY-5Kf4rOuTXElOgSHb5vxJoB-o70Oh0Bs-zxxUpHM0Ji_BPk2RpXoKdf8jG_QLPaulXWoC7TcEhDSLjj-4_l3hJpD0W_qBtoMGhT1MK1GRVFH1dnJolimMP7Z8a2tZA",
               "width" : 1296
            }
         ],
         "rating" : 3.90,

3 个答案:

答案 0 :(得分:2)

我一直想知道同样的事情。我读到了Picasa API,它似乎是这些图片的逻辑存储位置。

更新日期03-13-2013

此功能已作为Places API的一部分发布。请参阅链接以获取文档。 https://developers.google.com/places/documentation/photos

答案 1 :(得分:2)

谷歌还提供地方照片api,使用 photo_reference

从谷歌地图中检索照片
https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=photo_reference&key=AddYourOwnKeyHere

键: - 在此处传递您的应用程序API密钥。

maxwidth& maxheight: - api返回时所需的最大高度或宽度

photoreference: - 在这里传递您的照片参考。

向此api发送请求。它会让你回归。

图像类型取决于最初提交的照片的类型。

了解更多信息转到: - https://developers.google.com/places/documentation/photos

答案 2 :(得分:0)

插入HTML img标记中的photo_reference值

var photo_reference_goes_here = ['icon']['photos'][0]['photo_reference']

<img class="rig-img" src="https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=photo_reference_goes_here&key=GOOGLE_KEY" alt="Pic From Google">

相关问题