【问题标题】:Find all lat/long under certain radius查找特定半径下的所有纬度/经度
【发布时间】:2015-04-11 15:17:46
【问题描述】:

我有一组存储在数据库中的纬度/经度,我必须从数据库中找到位于给定纬度/经度(例如latitude = 37.4224764,and longitude=-122.0842499)和给定半径(比如 5 英里)之间的所有纬度/经度.为此,我需要做一些加法和减法,例如:

37.4224764 + 5mile 37.4224764 - 5mile

-122.0842499+5mile -122.0842499-5mile 但我不知道这里的转换是如何进行的。

【问题讨论】:

标签: math gps geospatial latitude-longitude spatial


【解决方案1】:

您的要求有点模糊,您只是想找出在给定方向上距您当前位置一定距离的点的坐标吗?或者在你的坐标周围获得一个特定距离半径的圆?或者从你的坐标画一条一定长度的线到另一个特定距离的点?

我假设您可能想使用Geometry spherical library,例如

var latLng = new google.maps.LatLng(geometry.location.lat, geometry.location.lng);

var newLatLng = google.maps.geometry.spherical.computeOffset(
    latLng,
    1000, 
    0
);

另见https://developers.google.com/maps/documentation/javascript/geometry#Distance

PS:加载地图时需要添加几何库参数:

<script src="https://maps.googleapis.com/maps/api/js?v=3&libraries=geometry"></script>

【讨论】:

  • 抱歉问题含糊不清,我已经更新了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-10
  • 1970-01-01
  • 1970-01-01
  • 2018-09-09
  • 2021-06-02
相关资源
最近更新 更多