Google Places API再次按城市搜索

时间:2013-09-05 19:50:30

标签: google-maps google-maps-api-3 google-places-api

我想搜索纽约的所有咖啡馆和餐馆。当然,我可以使用文本搜索,因为它在这里推荐 - Google Places API Search for Keyword and City

但是如果我提出要求的话 https://maps.googleapis.com/maps/api/place/textsearch/json?query=cafe+New+York+food&sensor=false&key=MY_KEY

我得到的第一个元素是

  

“formatted_address”:“316 Victoria Avenue,Chatswood NSW,Australia”,

真的无法按城市过滤数据吗?这个数据存在于地址中,为什么没有好的方法按城市过滤,只能通过关键字?

1 个答案:

答案 0 :(得分:5)

您可以在查询中添加location参数(还需要指定radius)。

所以你的查询看起来像是:

https://maps.googleapis.com/maps/api/place/textsearch/json?query=cafe+New+York+food&sensor=false&location=40.67,-73.94&radius=100&key=YOUR_KEY

请参阅此处的完整文档: https://developers.google.com/places/documentation/search#TextSearchRequests

相关问题