title: How to calculate distance between two marker points in android
body: <p>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:</p>
  
  <p>In MapsActivity.java</p>
  
  <pre><code>   private List&lt;LatLng&gt; getDirectionPolylines(List&lt;RouteObject&gt; routes){
          List&lt;LatLng&gt; directionList = new ArrayList&lt;LatLng&gt;();
          for(RouteObject route : routes){
              List&lt;LegsObject&gt; legs = route.getLegs();
              for(LegsObject leg : legs){
                  String routeDistance = leg.getDistance().getText();
                  String routeDuration = leg.getDuration().getText();
                  setRouteDistanceAndDuration(routeDistance, routeDuration);
                  List&lt;StepsObject&gt; steps = leg.getSteps();
                  for(StepsObject step : steps){
                      PolylineObject polyline = step.getPolyline();
                      String points = polyline.getPoints();
                      List&lt;LatLng&gt; singlePolyline = decodePoly(points);
                      for (LatLng direction : singlePolyline){
                          directionList.add(direction);
                      }
                  }
              }
          }
          return directionList;
      }
  </code></pre>
  
  <p>I am not clear how to calculate distance &amp; 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.</p>