以下是我想要的期望结果:
我想知道的是:
我使用中心点纬度和经度,以及其周围的半径创建了一个圆。现在,我想知道如何检查(计算)给定的纬度和经度是否位于该区域内或外。如果您能够提供JavaScript代码示例,我将不胜感激。我正在使用Google Maps API V3。
我找到了这个函数,但对我来说没有按预期工作:
function arePointsNear(checkPoint, centerPoint) {
var sw = new google.maps.LatLng(centerPoint.lat() - 0.005, centerPoint.lng() - 0.005);
var ne = new google.maps.LatLng(centerPoint.lat() + 0.005, centerPoint.lng() + 0.005);
var bounds = new google.maps.LatLngBounds(sw, ne);
if (bounds.contains (checkPoint)){
return true;
}
return false;
}
任何帮助都将是极好的...提前致谢!