如何连续计算位置更新之间的距离以获得总距离



如何连续计算位置更新之间的距离以获得总距离。我试图通过使用listview捕获时间t-1(以前的位置(和时间t(当前位置(的坐标,但没有得到好的结果。我在互联网上搜索过,到目前为止,我找到的解决方案是计算两点之间的距离。在我的问题中,将会有一系列的位置更新,从而产生坐标列表。请帮忙。

@Override
public void onLocationChanged(Location location) {
if (location !=null)
{
Lat=location.getLatitude();
Long=location.getLongitude();

// How to continuously calculate distance between location updates to finally get the total distance when I stop location update
}else{
Toast.makeText(getActivity(), "No location update", Toast.LENGTH_LONG).show();
}
}

返回总距离的位置为我提供了所需的结果。

最新更新