2

我看到来自 google 地方的 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,
4

3 回答 3

3

谷歌还提供地点照片 api 来使用photo_reference从谷歌地图中检索照片

https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=photo_reference&key=AddYourOwnKeyHere

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

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

照片参考:- 在此处传递您的照片参考。

向此 api 发送请求。它会返回你的形象。

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

有关更多信息,请转到:- https://developers.google.com/places/documentation/photos

于 2014-09-15T09:14:42.360 回答
2

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

2013 年 3 月 13 日更新

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

于 2012-12-06T16:36:48.477 回答
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">

于 2016-08-29T20:44:44.433 回答