问题描述
如何连续计算位置更新之间的距离以获得总距离。我试图通过使用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();
}
}
解决方法
我返回总距离的位置为我提供了理想的结果。