Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to draw a path on a map using kml file?
    text
    copied!<p>Can I parse kml file in order to display paths or points in Android? Please could you help me with that?</p> <p>This is kml sample code which I would like to display in android google map:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt; &lt;Document&gt; &lt;name&gt;Paths&lt;/name&gt; &lt;description&gt;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.&lt;/description&gt; &lt;Style id="yellowLineGreenPoly"&gt; &lt;LineStyle&gt; &lt;color&gt;7f00ffff&lt;/color&gt; &lt;width&gt;4&lt;/width&gt; &lt;/LineStyle&gt; &lt;PolyStyle&gt; &lt;color&gt;7f00ff00&lt;/color&gt; &lt;/PolyStyle&gt; &lt;/Style&gt; &lt;Placemark&gt; &lt;name&gt;Absolute Extruded&lt;/name&gt; &lt;description&gt;Transparent green wall with yellow outlines&lt;/description&gt; &lt;styleUrl&gt;#yellowLineGreenPoly&lt;/styleUrl&gt; &lt;LineString&gt; &lt;extrude&gt;1&lt;/extrude&gt; &lt;tessellate&gt;1&lt;/tessellate&gt; &lt;altitudeMode&gt;absolute&lt;/altitudeMode&gt; &lt;coordinates&gt; -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 &lt;/coordinates&gt; &lt;LineString&gt; &lt;/Placemark&gt; &lt;/Document&gt; &lt;/kml&gt; </code></pre> <p>When I'm loading this file to standard web google map it displays it nicely but when I'm trying the same thing with android google map it doesn't do that. It just takes me to some locations and that's it. I was thinking of changing listener class. Currently it looks like that:</p> <pre><code>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 } </code></pre> <p>Please can someone tell me what's I'm doing wrong here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload