Wie zeichne ich einen Pfad mit einer kml-Datei auf eine Karte?

Kann ich eine kml-Datei analysieren, um Pfade oder Punkte in Android anzuzeigen? Könntest du mir bitte dabei helfen?

Dies ist kml Beispielcode, den ich in Android Google Map anzeigen möchte:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Paths</name>
<description>Examples of paths. Note that the tessellate tag is by default
  set to 0. If you want to create tessellated lines, they must be authored
  (or edited) directly in KML.</description>
<Style id="yellowLineGreenPoly">
  <LineStyle>
    <color>7f00ffff</color>
    <width>4</width>
  </LineStyle>
  <PolyStyle>
    <color>7f00ff00</color>
  </PolyStyle>
</Style>
<Placemark>
  <name>Absolute Extruded</name>
  <description>Transparent green wall with yellow outlines</description>
  <styleUrl>#yellowLineGreenPoly</styleUrl>
  <LineString>
    <extrude>1</extrude>
    <tessellate>1</tessellate>
    <altitudeMode>absolute</altitudeMode>
    <coordinates> -112.2550785337791,36.07954952145647,2357
      -112.2549277039738,36.08117083492122,2357
      -112.2552505069063,36.08260761307279,2357
      -112.2564540158376,36.08395660588506,2357
      -112.2580238976449,36.08511401044813,2357
      -112.2595218489022,36.08584355239394,2357
      -112.2608216347552,36.08612634548589,2357
      -112.262073428656,36.08626019085147,2357
      -112.2633204928495,36.08621519860091,2357
      -112.2644963846444,36.08627897945274,2357
      -112.2656969554589,36.08649599090644,2357 
    </coordinates>
    <LineString>
    </Placemark>
    </Document>
    </kml>

Wenn ich diese Datei auf eine Standard-Google-Karte lade, wird sie gut angezeigt, aber wenn ich dasselbe mit Android Google Map versuche, funktioniert das nicht. Es bringt mich nur zu einigen Orten und das wars. Ich dachte daran, die Hörerklasse zu wechseln. Derzeit sieht es so aus:

private class MyLocationListener implements LocationListener 
{
    @Override
    public void onLocationChanged(Location loc) {
        if (loc != null) {
            latitude = (loc.getLatitude() * 1E6);
            longitude = (loc.getLongitude() * 1E6);
             Toast.makeText(getBaseContext(), 
                     "Location changed : Lat: " + latitude + 
                     " Lng: " + longitude, 
                     Toast.LENGTH_SHORT).show();

             GeoPoint p = new GeoPoint(
                     (int) (loc.getLatitude() * 1E6), 
                     (int) (loc.getLongitude() * 1E6));

             mc.animateTo(p);
             mapView.invalidate();
           }
    }

//---------------------------------------------------------------
    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub
    }

    @Override
    public void onStatusChanged(String provider, int status, 
        Bundle extras) {
        //TODO Auto-generated method stub
    }

Bitte kann mir jemand sagen, was ich hier falsch mache?

Antworten auf die Frage(8)

Ihre Antwort auf die Frage