【问题标题】:Google Places API - Counting the total number of places in a given radius around a lat / long?Google Places API - 计算纬度/经度周围给定半径内的地点总数?
【发布时间】:2012-05-24 15:50:35
【问题描述】:

有点不寻常的请求,但只是想知道是否有人知道一种方法来计算 Google Places 地点数据库中以纬度/经度为中心的给定半径(或多边形)内的地点总数?

非常感谢!

【问题讨论】:

  • 好问题。它会工作的家伙

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


【解决方案1】:

无法通过 Places API 查询 Google 数据库中给定半径范围内的地点总数。当您查询 Places API 时,将返回的最大结果数为 20(二十),如以下问题/答案中所述:What is the proper way to use the radius parameter in the Google Places API?

【讨论】:

    【解决方案2】:

    也许我误读了这个问题,但这里是。查看Places API example;它的搜索结果是一个数组,因此您可以将results.length 读取为找到的位置数(由请求返回,见下文)。围绕 latLng 或矩形边界的覆盖半径在请求中设置。

    function callback(results, status) {
      if (status == google.maps.places.PlacesServiceStatus.OK) {
        for (var i = 0; i < results.length; i++) {
          var place = results[i];
          createMarker(results[i]);
        }
      }
    }
    

    【讨论】:

    • 嗨,想法是完美的。但是,直到现在我还没有得到价值。请帮忙
    • 我明白了,谢谢你的想法......,有一点点变化 -- var place = results.length;像这样你必须这样做。它会起作用的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-01
    • 2014-03-19
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 2014-01-21
    相关资源
    最近更新 更多