title: Google direction route from current location to known location
body: <p>I use the <code>MapsActivity</code> class in this project. On my map you can see many markers. I have many known locations, but in my code I just display two locations for example.</p>
  
  <p>I don't understand how to use the direction API and JSON. How can I display the route, distance, and travelling time from my current location (changing) to a known location (constant)?</p>
  
  <pre><code>public class MapsActivity extends FragmentActivity {
  
      private GoogleMap mMap; // Might be null if Google Play services APK is not available.
      private Map&lt;Marker, Class&lt;?&gt;&gt; allMarkersMap = new HashMap&lt;Marker, Class&lt;?&gt;&gt;();
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_maps);
          setUpMapIfNeeded();
      }
  
      private void setUpMap() {
          Marker marker1 = mMap.addMarker(new MarkerOptions()
                  .position(new LatLng(14.608177, 120.967422))
                  .title("Sample2")
                  .snippet("zzzzzzz"));
          allMarkersMap.put(marker1, MainActivity.class);
  
          Marker marker2 = mMap.addMarker(new MarkerOptions()
                  .position(new LatLng(14.611335, 120.962160))
                  .title("Sample1")
                  .snippet("sssssss"));
          allMarkersMap.put(marker2, MainActivity2Activity.class);
          mMap.setMyLocationEnabled(true);
  
          mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
              @Override
              public void onInfoWindowClick(Marker marker) {
                  Class&lt;?&gt; cls = allMarkersMap.get(marker);
                          Intent intent = new Intent(MapsActivity.this, cls);
                  startActivity(intent);
              }
          });
      }
  </code></pre>