【问题标题】:need photo_reference from google places api需要来自 Google Places api 的 photo_reference
【发布时间】:2013-01-22 00:57:51
【问题描述】:

我正在使用谷歌地方的 api 来获取照片,但我遇到了问题。这里是:

所以我正在使用来自 google 地方的 api。我得到一个地方的结果。但这是我保存结果的代码:

 @Key
public String id;

@Key
public String name;

@Key
public String reference;

@Key
public String icon;

@Key
public String vicinity;

@Key
public String website;

现在我从谷歌得到的结果是这样的:

"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
      "id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
      "name" : "Google Sydney",
      "photos" : [
         {
            "height" : 1536,
            "html_attributions" : [ "Van Google-gebruiker" ],
            "photo_reference" : "CoQBdQAAAPga2KHTGQ7bwXYWqWdcjk3ysuclkMPLwteQJQKCLDTNSIW3r3UXXph7Xvd1xDglxSo4Tj_kQ7PtbmEp7nFbXs8-_TgX15Uw3yvjSs6InXSypn9RXEG46sjFZ1jnIK53_mGtwPf9X2IAUriXYsBaSq-eQ5y5QN6XuzjxoAPm-MBjEhD6ijhkCpZni0RmQthFsmBaGhSFdmnUCWAm_yacKUUWCRvP1Ci7Sg",
            "width" : 2048
         },
         {
            "height" : 480,
            "html_attributions" : [ "Van Google-gebruiker" ],
            "photo_reference" : "CnRqAAAAP3g4h5maCy8vR4D--VmH_LCCdoo07fGP9nsi0EvYF_U9dsdmGf_pLNl71drFGkAi4DOHkyv1SD66iaRUL7C-C8Ywjh1I5Z5zexGdzmVV4ST9FKrPRQzW3nalzEF4cf2hJYPKD_QjcW9a-4mhR1eaihIQpipj9088MwpwIDEUiQ85PRoUENmOYDyfcp2INEjovgLgUVVx7k8",
            "width" : 640
         }
      ],

现在我只需要 photo_reference。我怎样才能做到这一点?因为它在一个数组中?我只需要第一个 photo_reference。

提前致谢

【问题讨论】:

  • 查看this doc 从json 中检索photo_reference 作为字符串后,您需要使用this API 从google place api 获取照片

标签: java php android json


【解决方案1】:

将此网址与您的密钥和您的 photo_reference 一起用于您的代码:

https://maps.googleapis.com/maps/api/place/photo?maxwidth=70&photoreference=CoQBdQAAAPga2KHTGQ7bwXYWqWdcjk3ysuclkMPLwteQJQKCLDTNSIW3r3UXXph7Xvd1xDglxSo4Tj_kQ7PtbmEp7nFbXs8-_TgX15Uw3yvjSs6InXSypn9RXEG46sjFZ1jnIK53_mGtwPf9X2IAUriXYsBaSq-eQ5y5QN6XuzjxoAPm-MBjEhD6ijhkCpZni0RmQthFsmBaGhSFdmnUCWAm_yacKUUWCRvP1Ci7Sg&sensor=true&key=YOURKEYHERE

记住:参数 maxwidth 可以设置为图片超过响应参数的限制:“height”:480

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    • 2019-12-20
    相关资源
    最近更新 更多