I have a kml file (residing locally) which I want to show on Maps in an app I am developing. In my search, I have hit into this post: How to draw a path on a map using kml file? several times. I find this method rather lengthy.
I just want to show markers as defined by my kml file. Is there a way to do this without parsing the file? after all, both kml and Maps API are Google's. Isn't there a way to tell that API to load map based on a particular kml file?
Display kml file with Google Maps Android API v2 without parsing
Asked Answered
Is there a way to do this without parsing the file?
Not presently.
after all, both kml and Maps API are Google's.
So is Google Docs, but there is no API to dump a spreadsheet onto your map, either.
Isn't there a way to tell that API to load map based on a particular kml file?
Not at present, sorry. You may wish to keep an eye on this feature request to see if and when it gets added.
+1 for the link to feature request. I shall definitely keep an eye. –
Nuclide
@jazz11: BTW, I am assuming from your tags that you are referring to the native Android API for Google Maps known as Maps V2. If you are embedding a JavaScript version of Google Maps in your app, perhaps via a
WebView
, there probably is a way to integrate KML into the map, though as I do not use the Maps JavaScript API, I do not know any of the details. –
Boni Yes. I am referring to Google Maps Android API v2. Using GoogleMap object to show maps to user in the app. I had a feeling that I could do something to initialise that object by data from kml file. But apparently not... –
Nuclide
There is an option of creating a KML file into Google Earth on PC. Then put that file into SD card and you can call that KML file into the activity. But the prerequisite for the following to work is, you need Google Earth installed on Device.
public void buttonClicked(View view)
{Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/APK/trek1.kml");
intent.setDataAndType(Uri.fromFile(file), "application/vnd.google-earth.kml+xml");
startActivity(intent);
}
Perhaps you may know this way.
The question is about Google Maps API for Android, not Google Earth or any other app. –
Persinger
That's how did it once and i needed google earth. I don't know if Google Maps is capable of opening kml file but Google earth can. –
Nitrile
Once again, it is not about an application. It is about a library. @J... wants to show overlay from KML on map inside the application that he develops. (By the way, Google Maps application is capable of opening KML too) –
Persinger
© 2022 - 2024 — McMap. All rights reserved.