Dem*_*mon 33 google-maps-api-3 google-places-api
我想开发一个地图应用程序,它将显示给定地点附近的银行.
我使用Places库进行搜索,每次只返回20个结果.如果我想要更多结果,我该怎么办?
Tro*_*ott 17
更新:由于我最初写了这个答案,API得到了增强,使得这个答案过时了(或者至少是不完整的).请参阅如何从Google Places API获得20+结果?欲获得更多信息.
原始答案:
该文件表示,Places API的返回最多20个结果.它并不表示有任何方法可以更改该限制.所以,简短的回答似乎是:你做不到.
当然,您可以通过对多个位置进行查询,然后合并/重复删除结果来对其进行伪造.然而,这是一种廉价的黑客攻击,并且可能效果不佳.我先检查一下,确保它不违反服务条款.
Edu*_*rdo 15
现在可以有超过20个结果(但最多60个),参数page_token被添加到API中.
返回先前运行的搜索的后20个结果.设置page_token参数将使用先前使用的相同参数执行搜索 - 将忽略除page_token之外的所有参数.
您也可以参考访问其他结果部分以查看有关如何进行分页的示例.
Google api在一个页面中获取20个结果,假设您要使用下一页20结果,那么我们使用google first pag xml结果中的next_page_token.
1) https://maps.googleapis.com/maps/api/place/search/xml?location=Enter latitude,Enter Longitude&radius=10000&types=store&hasNextPage=true&nextPage()=true&sensor=false&key=Enter Google_Map_key
Run Code Online (Sandbox Code Playgroud)
在第二步中,您使用第一页的next_Page_token数据
2)https://maps.googleapis.com/maps/api/place/search/xml?location=Enter Latitude,Enter Longitude&radius=10000&types=store&hasNextPage=true&nextPage()=true&sensor=false&key=enter google_map_key &pagetoken="Enter the first page token Value"
Run Code Online (Sandbox Code Playgroud)
小智 6
为了回应 Eduardo,Google 现在确实添加了这一点,但 Places 文档还指出:
可返回的最大结果数为 60。
所以它仍然有一个上限。同样仅供参考,正如 Google 所说,“next_page_token”何时生效有延迟:
发出 next_page_token 和它变得有效之间有一个短暂的延迟。
这是官方的 Places API 文档:
https://developers.google.com/places/documentation/
| 归档时间: |
|
| 查看次数: |
51240 次 |
| 最近记录: |