I am creating an android app which shows distance and duration of two marker points in the Map. In the onCreate() I have written the following code:
In MapsActivity.java
private List<LatLng> getDirectionPolylines(List<RouteObject> routes){
List<LatLng> directionList = new ArrayList<LatLng>();
for(RouteObject route : routes){
List<LegsObject> legs = route.getLegs();
for(LegsObject leg : legs){
String routeDistance = leg.getDistance().getText();
String routeDuration = leg.getDuration().getText();
setRouteDistanceAndDuration(routeDistance, routeDuration);
List<StepsObject> steps = leg.getSteps();
for(StepsObject step : steps){
PolylineObject polyline = step.getPolyline();
String points = polyline.getPoints();
List<LatLng> singlePolyline = decodePoly(points);
for (LatLng direction : singlePolyline){
directionList.add(direction);
}
}
}
}
return directionList;
}
I am not clear how to calculate distance & duration in 'getText' in the code above. I was not able to see some APIs like Distancebetween() which is using LtnLtg as references. Please suggest how to calculate the distance and duration values.