title: Draw path from KML file on Google Map V2
body: <p>I'd like to know how can I show a route contained in a KML file on Google Maps V2?</p>
  
  <p>I'm able to extract the values of the filed "coordinates" in the KML file, but I don't know why my class doen't show the path into the map component.</p>
  
  <p>This is my class:</p>
  
  <pre><code>public class Mappa extends FragmentActivity implements LocationListener {
      private GoogleMap googleMap;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_mappa);
  
          // Getting Google Play availability status
          int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
  
          if(status != ConnectionResult.SUCCESS) {
              int requestCode = 10;
              Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
              dialog.show();
          }
          else {
  
          // Getting reference to the SupportMapFragment of activity_main.xml
              SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
  
              // Getting GoogleMap object from the fragment
              googleMap = fm.getMap();
  
             // Enabling MyLocation Layer of Google Map
             googleMap.setMyLocationEnabled(true);
  
             // Getting LocationManager object from System Service LOCATION_SERVICE
             LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
  
             // Creating a criteria object to retrieve provider
             Criteria criteria = new Criteria();
  
             // Getting the name of the best provider
             String provider = locationManager.getBestProvider(criteria, true);
  
             // Getting Current Location
             Location location = locationManager.getLastKnownLocation(provider);
  
             if(location!=null){
                 onLocationChanged(location);
             }
             locationManager.requestLocationUpdates(provider, 20000, 0, this);
  
             new LoadPath().execute(Environment.getExternalStorageDirectory().getPath() + "FILE.kml");
          } 
      }
  
  @Override
  public void onLocationChanged(Location location) {
  
           // Getting latitude of the current location
           double latitude = location.getLatitude();
  
           // Getting longitude of the current location
           double longitude = location.getLongitude();
  
          // Creating a LatLng object for the current location
          LatLng latLng = new LatLng(latitude, longitude);
  
          // Showing the current location in Google Map
          googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
  
          // Zoom in the Google Map
          googleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
  }
  
  @Override
  public vo id onProviderDisabled(String provider) { }
  
  @Override
   public void onProviderEnabled(String provider) { }
  
  @Override
  public void onStatusChanged(String provider, int status, Bundle extras) { }
  
   private class LoadPath extends AsyncTask&lt;String, Void, Void&gt;{
  
      Vector&lt;PolylineOptions&gt; path;
      Vector&lt;Vector&lt;LatLng&gt;&gt; path_fragment;
      Vector&lt;Polyline&gt; lines;
  
      @Override
      p rotected void onPreExecute() {
          super.onPreExecute();
          path_fragment = new Vector&lt;Vector&lt;LatLng&gt;&gt;();
          path = new Vector &lt;PolylineOptions&gt;();
          lines = new Vector&lt;Polyline&gt;();
       }
  
      @Override
      protected Void doInBackground(String... params) {
          try {
              InputStream inputStream = new FileInputStream(params[0]);
  
              DocumentBuilder docBuilder =  DocumentBuilderFactory.newInstance().newDocumentBuilder();
  
              Document document = docBuilder.parse(inputStream);
  
               NodeList listCoordinateTag = null;
  
              if (document == null) {
                  return null;
              }
  
              listCoordinateTag = document.getElementsByTagName("coordinates");
  
              for (int i = 0; i &lt; listCoordinateTag.getLength(); i++) {
  
                  String coordText = listCoordinateTag.item(i).getFirstChild().getNodeValue().trim();
                  String[] vett = coordText.split("\\ ");
                  Vector&lt;LatLng&gt; temp = new Vector&lt;LatLng&gt;();
                  for(int j=0; j &lt; vett.length; j++){
                      temp.add(new LatLng(Double.parseDouble(vett[j].split("\\,")[0]),Double.parseDouble(vett[j].split("\\,")[1])));
                  }
                  path_fragment.add(temp);
              }
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (ParserConfigurationException e) {
              e.printStackTrace();
          } catch (SAXException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          super.onPostExecute(result);
  
          googleMap.clear();
              for(int i=0; i &lt; path_fragment.size(); i++){
  
                  // Poliline options
                  PolylineOptions temp = new PolylineOptions();
  
                  for(int j=0; j&lt; path_fragment.get(i).size(); j++)
                  temp.add(path_fragment.get(i).get(j));
  
                  path.add(temp);
          }
  
              for(int i = 0; i &lt; path.size(); i++)
                  lines.add(googleMap.addPolyline(path.get(i)));
  
              for(int i = 0; i &lt; lines.size(); i++){
                 lines.get(i).setWidth(4);
                 lines.get(i).setColor(Color.RED);
                 lines.get(i).setGeodesic(true);
                 lines.get(i).setVisible(true);
              }
  
      }
  
  }
  
  }
  </code></pre>
  
  <p>In this way, I can get all the different coordinates int the following way:</p>
  
  <p>Latitude - Longitude - Altitude</p>
  
  <p>xxxxxxxx - xxxxxxxxx - xxxxxxxx</p>
  
  <p>yyyyyyyy - yyyyyyyyy - yyyyyyyy</p>
  
  <p>zzzzzzzz - zzzzzzzzz - zzzzzzzz </p>
  
  <p>But I'm not able to show them on the map.
  Can you help me please?</p>