Google Places API - 计算围绕纬度/经度的给定半径内的总地点数?

时间:2012-05-24 15:50:35

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

略有不同寻常的请求,但只是想知道是否有人知道如何计算Google地方信息位置数据库中在纬度/经度周围的给定半径(或多边形)内的总地点数?

非常感谢提前!

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分: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]);
    }
  }
}
相关问题