如何从谷歌地图搜索特定区域的用户?



>我有很多用户使用他们的纬度,长期在节点js服务器中使用mongodb。

现在我将输入一个位置,比如纽约。 它将通过地理编码 API 转换为 LAT LNG,并在半径 10 英里内进行搜索。现在我想找出哪些用户在该地区与液化天然气匹配。我该怎么做这部分?

对不起,英语不好。

我假设你通过地理编码得到了纽约的位置。由于您有用户的坐标,因此您基本上可以通过简单的几何和数学技能将这些位置与纽约的位置进行比较。
userLat用户的纬度,userLng用户的经度。还有yorkLatyorkLng是纽约的坐标。您基本上可以设置以下等式:

locationDiff = Math.sqrt(Math.pow(yorkLng - userLng, 2) + Math.pow(yorkLat - userLat, 2)
//You could modify inside the if condition to make sure they both have the same unit
if(locationDiff <= 100000){
//This user is within the circle whose center is New York location and radius you provided
}

最新更新