【发布时间】:2012-05-24 15:50:35
【问题描述】:
有点不寻常的请求,但只是想知道是否有人知道一种方法来计算 Google Places 地点数据库中以纬度/经度为中心的给定半径(或多边形)内的地点总数?
非常感谢!
【问题讨论】:
-
好问题。它会工作的家伙
标签: google-maps google-maps-api-3 google-places-api
有点不寻常的请求,但只是想知道是否有人知道一种方法来计算 Google Places 地点数据库中以纬度/经度为中心的给定半径(或多边形)内的地点总数?
非常感谢!
【问题讨论】:
标签: google-maps google-maps-api-3 google-places-api
无法通过 Places API 查询 Google 数据库中给定半径范围内的地点总数。当您查询 Places API 时,将返回的最大结果数为 20(二十),如以下问题/答案中所述:What is the proper way to use the radius parameter in the Google Places API?。
【讨论】:
也许我误读了这个问题,但这里是。查看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]);
}
}
}
【讨论】: