我需要在多个方向上获得总距离,但是当我运行它时只显示当前距离。如图所示,当我点击第三个标记时,它只计算第二个方向(它应该是第一个和第二个)。非常感谢你:))
// Fetching i-th route
List<HashMap<String, String>> path = result.get(i);
// Fetching all the points in i-th route
for(int j=0;j<path.size();j++){
HashMap<String,String> point = path.get(j);
if(j==0){ // Get distance from the list
distance = (String)point.get("distance");
continue;
}else if(j==1){ // Get duration from the list
duration = (String)point.get("duration");
continue;
}
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
lineOptions.addAll(points);
lineOptions.width(3);
}
tvDistanceDuration.setText(" Distance :"+distance + ", Duration:"+duration);