gpt4 book ai didi

google-places-api - 如何从 Google Places API 获取城市景点图片

转载 作者:行者123 更新时间:2023-12-03 22:08:22 25 4
gpt4 key购买 nike

我使用 Google Places Photos Api,我想通过 placeid 或城市标题获取所选城市的景点图像。

我尝试了两种方法:

1. f.e.我发送请求(使用伦敦 placeid)

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY

从响应中获取位置
"lat": 51.5073509
"lng": -0.1277583

下一步是请求
https://maps.googleapis.com/maps/api/place/radarsearch/json?location=51.5073509,-0.1277583&radius=5000&types=park|church|cafe|food|bar|night_club|stadium|store&keyword=&key=API_KEY

响应包含许多带有 placeid 的对象,我将其用于新请求,例如 first
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ1eu1vwgIdkgRwjsifpZERQc&key=API_KEY

响应包含 photo_reference 对象,它是我的图像源的一部分
https://maps.googleapis.com/maps/api/place/photo?photoreference=CoQBcwAAAMLCk4X_WMliqIfISe-mgxRadycuzApodVcaCrTMGP6wQXJaquATedXMkvnjuLAfTG9xzBYQfSNm3iXV07wxHr_X_WDhfjz_yQjmqCYlKwYwK5hH-nl9qi-4ZZqKKtFuphFEY8ka25GYN2sTNMdd0v99j7YCzpR-lHJnl0zA9QoPEhBA5CnCgElBAU7Z92VTShg2GhQUes4fTRKiJlW6rYKYEaNilauWaA&key=API_KEY&maxwidth=1200

result image

这不是伦敦最好的照片......

2.
使用带有参数的文本搜索 query=sights+in+London
https://maps.googleapis.com/maps/api/place/textsearch/json?query=sights+in+London&key=API_KEY

此请求返回包含 photo_reference 对象的响应。
最后请求是
https://maps.googleapis.com/maps/api/place/photo?photoreference=CnRnAAAAlLsg47UJRPVLdM8_sUbeLSia70EJ_mTisVDfCDTVUYNXl-35BGqzRARtq-Lt1CNcBWy3sKigfBVuF0iCr9-xqp1khK2l5JV3806LKvZrHJCaONYW35UBxxIIwxvxV-df4I4hg6f_zgeeIkWXGSYQhhIQNGYJl0fvHb3HslymbhH1thoUdLhGe8rJVCnyl_y0xAagzkFWs-Y&key=API_KEY&maxwidth=1200

result image

我怎样才能得到像 these 这样的图像

最佳答案

Places API 现在直接返回伦敦等城市的一些照片。例如,您通过 Place ID 对伦敦的查询:

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJdd4hrwug2EcRmSrV3Vo6llI&key=API_KEY

包括 this photo of the Place of Westminster这也显示在谷歌地图上。

关于google-places-api - 如何从 Google Places API 获取城市景点图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29668889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com