Load KML on Maps on the device or emulator

Tutorials that use the MapActivity. Many using GPS functionality.

Load KML on Maps on the device or emulator

Postby shyamku1718 » Mon Nov 16, 2009 8:47 pm

Hi,

We are generating KML files for the traffic data we calculated and we want to show that on the map with Green,Red and yellow lines.This works fine on Google Earth if i load the KML there.

My requirement is i have to show the same on Google Maps on the device.

************ KML Sample ***********************

<?xml version="1.0" encoding="UTF-8" standalone="no"?><kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<LookAt>
<longitude>-73.7906468706933</longitude>
<latitude>42.75665628887243</latitude>
<altitude>0.0</altitude>
<range>2003.578208227112</range>
<altitudeMode>absolute</altitudeMode>
</LookAt>
<Placemark id="linestring1">
<name>My Path</name>
<description>18.0</description>
<Style id="LineColor">
<LineStyle>
<color>ff0000ff</color>
<width>5.0</width>
</LineStyle>
</Style>
<LineString>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>-73.76177154935891,42.74131112054128
-73.76161854935891,42.74337112054128
</coordinates>
</LineString>
</Placemark>
</Document></kml>

************ END *********************************

I used the following code to load my KML

Intent mapIntent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("geo:0,0?q=http://10.168.6.71/kmlTesting/kmlTesting.jsp?key=DM,USA");
mapIntent.setData(uri);
startActivity(Intent.createChooser(mapIntent, "Sample Map"));

******************************************************

I get the error "This community Map cannot be loaded it contains errors"


I tried capturing a route in google Earth - saved it as KML and used that one to refer in the above piece of code but still the same error.

Could you guys please help me it's really urgent.
shyamku1718
Freshman
Freshman
 
Posts: 3
Joined: Mon Nov 16, 2009 7:01 pm

Top

Re: Load KML on Maps on the device or emulator

Postby fwaokda » Sun Jul 04, 2010 3:35 pm

Anyone know how to correct this problem I'm getting an error too.
fwaokda
Freshman
Freshman
 
Posts: 8
Joined: Mon Feb 15, 2010 11:07 pm

Re: Load KML on Maps on the device or emulator

Postby fwaokda » Sun Jul 04, 2010 5:22 pm

Got it working here is what I used.

final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=http://www.mysite.com/locations.kml"));
startActivity(myIntent);

This will just show all your placemarks listed in the file. I'm gonna try and find a parser for the kml/kmz so I can insert the information into a database. :) -- If anyone has already done this I'd love to hear about it.
fwaokda
Freshman
Freshman
 
Posts: 8
Joined: Mon Feb 15, 2010 11:07 pm

Re: Load KML on Maps on the device or emulator

Postby theguire » Mon Jul 05, 2010 11:42 pm

Actually, I am working on this right now. I should be done today or tomorrow. I will let you know.
theguire
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Apr 13, 2010 4:01 am

Re: Load KML on Maps on the device or emulator

Postby fwaokda » Tue Jul 06, 2010 3:13 am

theguire, sweet thanks a lot. Right now I'm using a text file to update my database but kml would be much much better. Can't wait.
fwaokda
Freshman
Freshman
 
Posts: 8
Joined: Mon Feb 15, 2010 11:07 pm

Re: Load KML on Maps on the device or emulator

Postby gisaddict » Thu Jan 06, 2011 4:27 pm

could you post the solution for adding kml? I am very interested in getting this functionality.
gisaddict
Freshman
Freshman
 
Posts: 2
Joined: Thu Jan 06, 2011 4:24 pm

Top

Re: Load KML on Maps on the device or emulator

Postby gisaddict » Fri Jan 14, 2011 2:39 pm

Testing the solution provided to add a KML results in syntax errors:

final Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=http://maps.peachtree-city.org/Public/citylimit.kml"));
startActivity(myIntent);

"Syntax error on myIntent VariableDeclaratorID expected
myIntent can't be resolved as a type
return type missing"

Using Eclipse SDK v3.6.1
android sdk v8 Google API 2.2
gisaddict
Freshman
Freshman
 
Posts: 2
Joined: Thu Jan 06, 2011 4:24 pm

Re: Load KML on Maps on the device or emulator

Postby habiand » Sun Jul 22, 2012 4:10 pm

hello,
I am new to the android developpement world, and I need some guidances in how to load kml file into my mapview on android application!
anybody can help me !!
thx
habiand
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Jul 22, 2012 4:06 pm

Re: Load KML on Maps on the device or emulator

Postby dipzee » Fri Jul 26, 2013 12:43 pm

great
dipzee
Freshman
Freshman
 
Posts: 7
Joined: Wed Jul 17, 2013 7:18 am

Top

Return to Map Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests