【问题标题】:How to find the difference in meter between two geo points in maps?如何找到地图中两个地理点之间的米差?
【发布时间】:2014-07-23 15:09:08
【问题描述】:

根据当前用户位置了解列表中最近位置的最佳方法是什么。 有没有办法计算地图中两个地理点之间的差异?

【问题讨论】:

    标签: android google-maps


    【解决方案1】:

    您可以通过制作 2 个 Location 对象(每个点一个)并调用方法 distanceTo 来获取 2 个点之间的距离。

    示例。

    // Instantiate.
    Location pointOne=new Location("");
    Location pointTwo=new Location("");
    
    // Configure.
    pointOne.setLatitude(doubleValue);
    pointOne.setLongitude(doubleValue);
    pointTwo.setLatitude(doubleValue);
    pointTwo.setLongitude(doubleValue);
    
    // Calculate distance.
    float distanceInMeters=pointOne.distanceTo(pointTwo);
    

    仅此而已。 顺便说一句,注意你的语法以获得更好的可读性 =)

    祝你好运。

    【讨论】:

      猜你喜欢
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-10
      • 1970-01-01
      • 1970-01-01
      • 2013-03-20
      • 1970-01-01
      相关资源
      最近更新 更多