Google maps api 3 如何搜索谷歌地图API并获得多个位置?
我已经能够从谷歌地图向PlacesAPI发出请求,但我总是得到一个结果 例如,搜索“白宫”之类的内容或实际的街道地址,只会得到一个结果:Google maps api 3 如何搜索谷歌地图API并获得多个位置?,google-maps-api-3,google-places-api,google-places,Google Maps Api 3,Google Places Api,Google Places,我已经能够从谷歌地图向PlacesAPI发出请求,但我总是得到一个结果 例如,搜索“白宫”之类的内容或实际的街道地址,只会得到一个结果: https://maps.googleapis.com/maps/api/place/findplacefromtext/json ?input=the%20white%20house &inputtype=textquery &fields=formatted_address,name,geometry &key=AP
https://maps.googleapis.com/maps/api/place/findplacefromtext/json
?input=the%20white%20house
&inputtype=textquery
&fields=formatted_address,name,geometry
&key=API_KEY
response: {
candidates: [
{
formatted_address: "1600 Pennsylvania Ave NW, Washington, DC 20500, USA",
geometry: {
location: {
lat: 38.8976763,
lng: -77.0365298
},
viewport: {
northeast: {
lat: 38.90148105,
lng: -77.03520012010728
},
southwest: {
lat: 38.89640805000001,
lng: -77.03789977989273
}
}
},
name: "The White House"
}
],
status: "OK"
};
如果我想找到,老生常谈,我周围所有的星巴克怎么办?(如何限制搜索半径是后面的问题)
一些评论指出,我的“星巴克”搜索应该得到不同的回应。为什么我不行?你可以试试。请注意,没有办法限制附近的搜索请求只返回特定字段
请看下面的示例请求:
该响应将为您提供此特定位置的所有麦当劳门店38.8976763,-77.0365298。您还将注意到,有一个radius参数50000用于返回place结果。地理编码器需要一个地址作为输入,并且在大多数情况下只返回一个最接近的匹配。我不确定你是如何测试PlacesAPI的,但我通常会得到20个“星巴克”的结果(使用
SearchBox
)。相关问题:据我所知,半径的最大值是50000,这不是很多。所以,你不可能得到一个国家所有的多个地方。还有别的办法吗?
https://maps.googleapis.com/maps/api/place/findplacefromtext/json
?input=starbucks
&inputtype=textquery
&fields=formatted_address,name,geometry
&key=API_KEY
response: {
candidates: [],
status: "ZERO_RESULTS"
};