【问题标题】:Measure the distance between two locations by road通过道路测量两个位置之间的距离
【发布时间】:2016-01-16 23:30:39
【问题描述】:

如何在我的 Android 应用程序中通过道路测量两个位置之间的距离?我编写了测量直线距离的代码,但我需要道路最短距离的代码。我应该在我的代码中更改什么?

public double updateDistance(Location location) {
    float results[] = new float[3];
    Location.distanceBetween(location.getLatitude(),
            location.getLongitude(), mLatitude, mLongitude, results);
    distance = results[0];
    return distance;
}

【问题讨论】:

    标签: android distance measure


    【解决方案1】:

    【讨论】:

    • 是否有任何解决方案我不必更改所有代码?我的应用可以工作,但它测量我的位置和 xml 文件中的所有位置之间的直线。
    • 要获得公路距离,您需要地图。我看不出有什么办法。在不知道街道位置的情况下,您无法计算行驶距离,而且位置 API 和 GPS 坐标都没有该信息。抱歉,我不能给你更好的消息。
    • 我已经有了地图。但是在 MainActivity.class 我测量从我的位置到我的 xml 文件中的位置的距离,但它测量的是直线。这是代码:
    • private void updateLocation(Location location) { mCurrentLocation = location; for (Tour tour : tours) { double distance = tour.updateDistance(location); datasource.updateTourDistance(旅游,距离); } 刷新显示(); }
    猜你喜欢
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-22
    • 1970-01-01
    • 2011-03-16
    • 1970-01-01
    相关资源
    最近更新 更多