【问题标题】:Android find bearing on a fixed locationAndroid 找到固定位置的方位
【发布时间】:2012-01-28 19:59:16
【问题描述】:

我对 Android 非常陌生,并且通过它学习。所以我想创建一个像指针一样的箭头来显示固定位置的固定位置,当用户移动他们的设备时,箭头应该会自动更新(如指南针)。

我已经搜索了资源,但我无法找到它。这里有人知道怎么做吗?任何示例或教程将不胜感激。

例子:

fixed location: 20 latitude, 50 longitude
my location: 5 latitude 25, longitude
So how do i find the arrow pointed to fixed location?

【问题讨论】:

    标签: android


    【解决方案1】:

    如果 curLat 和 curLon 是当前位置的纬度和经度,如果 refLat 和 refLon 是参考位置的纬度和经度,您可以像这样得到从当前位置到参考位置的方位:

    final float[] results= new float[3];
    // The computed distance in meters is stored in results[0].
    // If results has length 2 or greater, the initial bearing is stored in results[1].
    // If results has length 3 or greater, the final bearing is stored in results[2].
    Location.distanceBetween(curLat, curLon, refLat, refLong, results);
    final float bearing = results[1];
    

    如果距离增加,结果 [2] 与结果 [1] 的差异越来越大,除非从当前位置到参考位置的路线遵循恒向线(或等轴线,参见此处:http://en.wikipedia.org/wiki/Rhumb_line)。

    【讨论】:

      猜你喜欢
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多