简体   繁体   English

需要Google Places API的photo_reference

[英]need photo_reference from google places api

I'm using the api of google places to get photos but I got a problem. 我正在使用Google Places的api来获取照片,但是遇到了问题。 Here it is: 这里是:

So I'm using the api from google places. 所以我正在使用Google Places的API。 And i get the results of a place. 我得到一个地方的结果。 But here is the code where I keep the results: 但是以下是我保留结果的代码:

 @Key
public String id;

@Key
public String name;

@Key
public String reference;

@Key
public String icon;

@Key
public String vicinity;

@Key
public String website;

Now the results I get back from google are this: 现在我从谷歌那里得到的结果是:

"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
         }
      ],

Now I only need the photo_reference. 现在我只需要photo_reference。 How can I do that? 我怎样才能做到这一点? Because it's in a array? 因为它在数组中? I only need the first photo_reference. 我只需要第一个photo_reference。

Thanks in advance 提前致谢

Use this url on your code with your key and your photo_reference: 在您的代码中将此URL与您的密钥和photo_reference一起使用:

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

Remember: the param maxwidth can be set until the limit on picture over your response param: "height" : 480 请记住:可以设置参数最大宽度,直到响应参数的图片限制:“ height”:480

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM