如何从谷歌地图或地方API一个地方的图片 [英] How to get a picture of a place from google maps or places API
问题描述
我使用的是谷歌的地方API来检索有关地方的数据,但怎么也找不到让那个地方的图片,谷歌API的地方正好提供了图标,这是不一样的。我需要你的照片,当您搜索在谷歌地图的地方在网络浏览器为例。通常有来自Panoramio的更多的图片,但Panoramio的API只能搜索图片按位置,而不是由一个特定的餐馆或酒店名称,例如。任何想法?
I'm using Google Places API to retrieve data about places, but couldn't find how to get a picture of that place, Google Places API just provides icon which is not the same. I need the photo you get when you search for a place in Google Maps in a web browser for example. There is usually more pictures from Panoramio, but Panoramio API can only search for pictures by location and not by a particular restaurant or hotel name for example. Any ideas?
推荐答案
该API的地方会给你的坐标(经度和纬度)在的到位详细回应;那么你可以发送坐标到 Panoramio的API 。
The Places API will give you the coordinates (latitude and longitude) in the place detail response; you can then send the coordinates to the Panoramio API.
例如(在API文档的范例中):
For example (drawing from examples in the API docs):
https://maps.googleapis.com/maps/api/place/details/json?reference=<big长键到位&GT;&放大器;传感器=真放大器;关键= AIzaSyAiFpFd85eMtfbvmVNEYuNds5TEF9FjIPI
响应:的
{
"html_attributions" : [],
"result" : {
"address_components" : [
{
"long_name" : "48",
"short_name" : "48",
"types" : [ "street_number" ]
},
{
"long_name" : "Pirrama Road",
"short_name" : "Pirrama Road",
"types" : [ "route" ]
},
{
"long_name" : "Pyrmont",
"short_name" : "Pyrmont",
"types" : [ "locality", "political" ]
},
{
"long_name" : "NSW",
"short_name" : "NSW",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "AU",
"short_name" : "AU",
"types" : [ "country", "political" ]
},
{
"long_name" : "2009",
"short_name" : "2009",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "5/48 Pirrama Road, Pyrmont NSW, Australia",
"formatted_phone_number" : "(02) 9374 4000",
"geometry" : {
"location" : {
"lat" : -33.8669710,
"lng" : 151.1958750
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png",
"id" : "4f89212bf76dde31f092cfc14d7506555d85b5c7",
"international_phone_number" : "+61 2 9374 4000",
"name" : "Google Sydney",
"rating" : 4.60,
"reference" : "CnRlAAAAAfV6JIqSzL8Cf4VnXn0EaI1d5k3IPhdkEonq0MxiUbQFFSVuptVbXbNH4mrevb0bc7G8yWqTUv76i4KTuO_Wf3OrRHjCJJwzQ0mNLjbYGSVqy2eqyrgOUkl6S_sJfTbHzWZYrfPy7KZaet0mM5S6thIQJYuy5v_JD--ZxXEJLWTQRRoU5UaciXBBo89K-bce18Ii9RsEIws",
"types" : [ "store", "establishment" ],
"url" : "http://maps.google.com/maps/place?cid=10281119596374313554",
"vicinity" : "5/48 Pirrama Road, Pyrmont",
"website" : "http://www.google.com.au/"
},
"status" : "OK"
}
我们可以看到,坐标 位置 : { 纬度:-33.8669710, 液化天然气:151.1958750 }
We can see that the coordinates are "location" : { "lat" : -33.8669710, "lng" : 151.1958750 }
然后,我们可以将请求发送到Panoramio的,插入的坐标,加在任一侧稍微回旋余地(我确实+/- 0.002度,形状200米×200米平方在赤道,通常更小)。 <$c$c>http://www.panoramio.com/map/get_panoramas.php?set=public&from=0&to=20&minx=-33.868&miny=151.193&maxx=-33.864&maxy=151.197&size=medium&mapfilter=true$c$c>
Then we can send a request to Panoramio, inserting the coordinates, plus a little wiggle room on either side (I did +/- 0.002 degrees, a shape 200 m x 200 m square at the equator, generally smaller).
http://www.panoramio.com/map/get_panoramas.php?set=public&from=0&to=20&minx=-33.868&miny=151.193&maxx=-33.864&maxy=151.197&size=medium&mapfilter=true
您可能需要做响应的一些过滤得到最接近的照片,但是这应该给你一些帮助。
You may need to do some filtering of the responses to get the closest photo, but this should give you something to work with.
这篇关于如何从谷歌地图或地方API一个地方的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!