【问题标题】:creating LatLngBounds for 50Mile radius with current location使用当前位置为 50 英里半径创建 LatLngBounds
【发布时间】:2016-03-27 10:35:06
【问题描述】:

我想为 50 英里半径 wrt 创建 LatLngBounds。当前位置。与 google 地方 api 一起使用。

现在,我在网上做一个例子

//Southwest corner to Northeast corner.
LatLngBounds bounds = new LatLngBounds(
                          new LatLng(39.906374, -105.122337), 
                          new LatLng(39.949552, -105.068779)
                      );

你能提供指点吗?

更新:

我用这个作为答案:

How to convert a LatLng and a radius to a LatLngBounds in Android Google Maps API v2?

【问题讨论】:

标签: android


【解决方案1】:

我假设您知道如何确定用户的位置。有很多关于这个主题的信息。

所以,主要的问题是找出要用作边界的角。这被称为直接测地线问题(参见:https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid)。你有几种方法可以解决它:

  1. 使用java库(http://geographiclib.sourceforge.net/html/java/)计算角点坐标,方法如下:

    Geodesic.WGS84.Direct(lat1, lon1, azi1, s12)

    (请参阅文档:http://geographiclib.sourceforge.net/html/java/net/sf/geographiclib/Geodesic.html

    请注意,您必须确定沿途的方位角。

  2. 使用内置的 android.location.Location 类。它有一个静态方法“distanceBetween”,它获取两点的坐标并计算它们之间的距离。

    这里的重点是使用“分而治之算法”来查找边界矩形的上/下纬度和左/右经度。

  3. 如果精度不成问题,请使用固定值将距离转换为近似纬度/经度。

【讨论】:

    猜你喜欢
    • 2019-02-20
    • 1970-01-01
    • 2011-06-28
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多