简体   繁体   中英

How to prepare KML file for Android Emulator Control?

I am trying to test my application with location information. You know the Emulator Control has an ability to load from KML file. (Eclipse -> DDMS -> Emulator Control -> Location Controls -> KML -> Load KML...) I've prepared KML file using Google earth application with its "Add path". Then saved it by .kml extension and load it on the Eclipse. Eclipse didn't load this KML file.

How to prepare KML file for Android Emulator Control?

I've found solution : KML format is :

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.x">
<Placemark>
    <name>1</name>
        <Point><coordinates>-109.0450005395891,33.39487928579279,0</coordinates></Point>
</Placemark>
</kml>

The KML format that's accepted by ADT (0.8.x) differs from the Google Earth (or even Google Tracks) format.

Convert the original KML file at http://ge2adt.appspot.com/ , use your Google account to login.

You can now try to open the file in the emulator control. I still couldn't open the KML file in the emulator. Open the KML file and remove the 'Document' element, don't delete the 'Placemark' elements. Also check if there multiple KML definitions ('kml' element). I had two definitions with only one placemark, and one correct definition with multiple placemarks. Delete the definitions with only one placemark.

The KML file must be a 3D file - some GIS tools (eg QGIS ) don't put the Z value in the output if it is not present in your input data. A simple search and replace to add ,0 before each closing </coordinate> tag will solve this problem.

Just tested this, and found actually the only thing you need to change to get the ADT to accept your KML file is to change the namespace to http://earth.google.com/kml/2.x .

You'd think someone at Google would have sorted this out by now...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM