KML Structure Requirements
- KML file must be compressed into a .KMZ archive
- Placemarks MUST be wrapped into folders
- Folders MUST be wrapped into the <Document> node
- Each folder MUST have a unique ID attribute
- Placemarks MUST be assigned unique IDs
- Nested folders are permitted. However, intermediate folders MUST NOT contain placemarks
- Leaf folders SHOULD contain placemarks of same geometry type (except multigeometry)
- Leaf folders SHOULD contain placemarks of same logic group (e.g. manholes, utility poles, etc.)
- Polygons
- The <coordinates> for polygons must be specified in counterclockwise order
- At the moment, only the outer boundary of polygon is supported in KML
- <kml> node should have a valid xmlns attribute
Common Issues
- Placemarks are not wrapped into folders
- The file is missing the <Document> node(s)
- The file is missing the <Folder> node(s)
- ID property is missing from the <Folder> node(s)
- ID property is missing from the <Placemark> node(s)
- Model's texture is not mapped within the <ResourceMap> node
Example
<?xml version="1.0" encoding="UTF-8"?>
<kml
xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<Folder
id="Model">
<Placemark
id="model1">
<name>test_kml</name>
<description>test
</description>
<Model
id="model1">
<altitudeMode>absolute
</altitudeMode>
<Location>
<longitude>6.1103670152
</longitude>
<latitude>45.8909933031
</latitude>
<altitude>-49.4505667663
</altitude>
</Location>
<Orientation>
<heading>0.0000000000
</heading>
<tilt>0.0000000000
</tilt>
<roll>0.0000000000
</roll>
</Orientation>
<Scale>
<x>1.0000000000
</x>
<y>1.0000000000
</y>
<z>1.0000000000
</z>
</Scale>
<Link>
<href>model.dae
</href>
</Link>
<ResourceMap>
<Alias>
<targetHref>model.1001.jpg
</targetHref>
<sourceHref>model.1001.jpg
</sourceHref>
</Alias>
</ResourceMap>
</Model>
</Placemark>
</Folder>
</Document>
</kml>