title: Route directions for driving mode
body: <p>I'm trying to implement a route direction for the points I have on my map, for doing that I'm using Polyline, the problem is, I managed to connect 2 points of the map, but I have an array of LatLng with 8 points, how would I connect all the points?:</p>
  
  <pre><code>  @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
          setContentView(R.layout.maps);
  
  
          ArrayList&lt;LatLng&gt; coordList = new ArrayList&lt;LatLng&gt;();
          ArrayList&lt;String&gt; nomes = new ArrayList&lt;String&gt;();
          try {
  
              Bundle parametros = getIntent().getExtras();
              rm_IdViagem = parametros.getString("id_viagem");
  
              Repositorio ca = new Repositorio(this);
              mViagemModel = ca.getViagemPorId(Integer.valueOf(rm_IdViagem));
  
              Repositorio cl = new Repositorio(this);
              mClienteModel = cl.getClientesViagem(Integer.valueOf(rm_IdViagem));
  
  
              if(mClienteModel != null) {
  
                  for (int i = 0; i &lt; mClienteModel.size(); i++) {
  
  
                      Repositorio mRepositorio = new Repositorio(this);
                      mEnderecoModel = mRepositorio.getListaEnderecosDoCliente(Integer.valueOf(mClienteModel.get(i).getClientes_id()));
  
  
                      for (int j = 0; j &lt; mEnderecoModel.size(); j++) {
                          // Loading map
                          initilizeMap();
                          // Changing map type
                          googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
                          // googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
                          // googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
                          // googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
                          // googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
  
                          // Showing / hiding your current location
                          googleMap.setMyLocationEnabled(true);
  
                          // Enable / Disable zooming controls
                          googleMap.getUiSettings().setZoomControlsEnabled(true);
  
                          // Enable / Disable my location button
                          googleMap.getUiSettings().setMyLocationButtonEnabled(true);
  
                          // Enable / Disable Compass icon
                          googleMap.getUiSettings().setCompassEnabled(true);
  
                          // Enable / Disable Rotate gesture
                          googleMap.getUiSettings().setRotateGesturesEnabled(true);
  
                          // Enable / Disable zooming functionality
                          googleMap.getUiSettings().setZoomGesturesEnabled(true);
  
  
                          final float latitude = Float.parseFloat(mEnderecoModel.get(j).getLatitude());
                          final float longitude = Float.parseFloat(mEnderecoModel.get(j).getLongitude());
  
  
  
                          nomes.add(mClienteModel.get(i).getNome());
  
  
                          coordList.add(new LatLng(latitude, longitude));
  
                          googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 5));
  
  
  
                          mClusterManager = new ClusterManager&lt;MyItem&gt;(MapaViagem.this, googleMap);
  
  
                          mClusterManager.setRenderer(new MyClusterRenderer(MapaViagem.this, googleMap, mClusterManager));
  
                          googleMap.setOnCameraChangeListener(mClusterManager);
                          googleMap.setOnMarkerClickListener(mClusterManager);
  
                          //mClusterManager.setAlgorithm(new GridBasedAlgorithm&lt;MyItem&gt;());
  
  
  
  
                          addItems(coordList, nomes);
  
  
                          mClusterManager.cluster();
  
  
  
  
  
                  }
  
  
              }
          }
  
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  
  
  public class MyClusterRenderer extends DefaultClusterRenderer&lt;MyItem&gt; {
  
      public MyClusterRenderer(Context context, GoogleMap map,
                               ClusterManager&lt;MyItem&gt; clusterManager) {
          super(context, map, clusterManager);
      }
  
      @Override
      protected void onBeforeClusterItemRendered(MyItem item, MarkerOptions markerOptions) {
          super.onBeforeClusterItemRendered(item, markerOptions);
  
          markerOptions.title(String.valueOf(item.getName()));
      }
  
      @Override
      protected void onClusterItemRendered(MyItem clusterItem, Marker marker) {
          super.onClusterItemRendered(clusterItem, marker);
  
  
  
          //here you have access to the marker itself
      }
  
      @Override
      protected boolean shouldRenderAsCluster(Cluster&lt;MyItem&gt; cluster) {
          return cluster.getSize() &gt; 1;
      }
  
  
  
  }
  </code></pre>