douchuang1861 2013-04-17 11:04
浏览 25
已采纳

谷歌地图全球搜索

I am trying to use google places textSearch to discover all stores of certain brand (lets say Levi's) so I will iterate through the results by using next_page_token, but I seem to hit the issue of the max 60 results that are returned. Can this results be lifted somehow or does anyone know of another service that can provide this kind of results ?

  • 写回答

1条回答 默认 最新

  • dpp3047 2013-04-17 11:39
    关注

    There is sadly no way around the 60-entry restriction other than clever polling on textsearch, and the results cannot be sorted. Your best solution would be nearbySearch. The API parameters are almost the same as textsearch, with three differences:

    • Your radius will be automatically set to 50km
    • rankby=distance allows you to sort results by distance from your location (you will see why this is important)
    • query becomes keywords and is no longer a true Google Maps search parameter - just a list of keywords

    The results that come back are similar to the textSearch returns - and they come with a unique ID, which will come in handy as well.

    How to scan everything

    Scanning an area is pretty simple. You're limited to 60 results per query - so what we will do is sort by distance, so that we know for sure that our last result of the set is also the furthest. This allows you to build a maximum likely radius for your request - and the base your next search on this.

    Here is a simulated result on photoshop. I ran a random request based on a point in France and mapped the radius of the search using the green circle:

    The first query

    The green circle denotes the results. This allows me to formulate three new queries, all three on the edge of the current zone (but inside it):

    Second round of queries

    You will notice that the first query is fully covered by the second. This allows you to get the entirety of results in an area with as little overlap as possible, and to efficiently sort them by ID (so you know you do not have duplicated).

    Caveat: a 50km radius (max) will take 1 query. A 95km radius takes four. A 140km radius takes 13. It quickly ramps up - so if I were you, I'd cache results somewhere.

    The id return field is guaranteed unique - the reference is bound to your API key. The difference? The reference allows you to fire a Place Details request to get updated info on a place (some info here).

    Hope this helped clear a few things up.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF动态创建页面内容
  • ¥15 如何对TBSS的结果进行统计学的分析已完成置换检验,如何在最终的TBSS输出结果提取除具体值及如何做进一步相关性分析
  • ¥15 SQL数据库操作问题
  • ¥100 关于lm339比较电路出现的问题
  • ¥15 Matlab安装yalmip和cplex功能安装失败
  • ¥15 加装宝马安卓中控改变开机画面
  • ¥15 STK安装问题问问大家,这种情况应该怎么办
  • ¥15 关于罗技鼠标宏lua文件的问题
  • ¥15 halcon ocr mlp 识别问题
  • ¥15 已知曲线满足正余弦函数,根据其峰值,还原出整条曲线