user1291437
user1291437

Reputation: 81

upload kml map to my android app

i tried to find how i could load kml file and I found that I can use:

    Intent mapIntent = new Intent(Intent.ACTION_VIEW); 
    Uri uri1 = Uri.parse("geo:0,0?q=http://code.google.com/apis/kml/ 
    documentation/KML_Samples.kml"); 
    mapIntent.setData(uri1); 
    startActivity(Intent.createChooser(mapIntent, "Sample")); 

is there any other way such that i can upload the kml file locally from my pc rather than having to upload it to a website, then use it..as I am developing an applications and usually other users wont be able to access the kml of they dont have the username and password for the link

please if anyone can help, I would be thankful.

Upvotes: 1

Views: 445

Answers (2)

amit semwal
amit semwal

Reputation: 415

KML map in android is now officially available on this link.

You can easily load KML file from local resource folder or from inputstreams into your android app as below.

From local resource:-

KmlLayer layer = new KmlLayer(map, R.raw.geojson_file, context);

From InputStreams:-

InputStream inputStream = // InputStream containing KML data
KmlLayer layer = new KmlLayer(map, inputStream, context);

Upvotes: 0

Miki
Miki

Reputation: 26

You can create an account in googlecode and upload the kml file, so it'll be on the internet and everybody can see it

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Uri uri = Uri.parse("geo:0,0?q=http://miruta.googlecode.com/files/miruta.kml");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, uri);
mapIntent.setData(uri);
startActivity(Intent.createChooser(mapIntent, "Sample Map")); 
}

Upvotes: 1

Related Questions