Search code examples
kmlgoogle-earth

kml, High Performance KML for Maps and Earth, not working


I made a KML file to mimic an example from " High Performance KML for Maps and Earth'-on YouTube-link (at 15:11-16:05 or just 15:51)

I get the error:

Validation stopped at line 2, column 45: no declaration found for element 'kml'

When I try to run this code GOOGLE EARTH crashes.

Here is my code:

<?xml  version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<gx:Track>
 <when>13:51</when>
  <gx:coord>-147.871 64.861</gx:coord>
    <ExtendedData>
     <SchemaData  schemaUrl="#schema">
       <gx:SimpleArrayData  name="PM 2.5">
            <gx:value>0.0</gx:value>
            <gx:value>-6.0511e+15</gx:value>
            <gx:value>180</gx:value>
        </gx:SimpleArrayData>
     </SchemaData>
    </ExtendedData>
</gx:Track>
</Placemark>
<Placemark>
 <gx:Track>
  <when>13:56</when>
   <gx:coord>-147.871 64.861</gx:coord>
    <ExtendedData>
     <SchemaData  schemaUrl="#schema">
       <gx:SimpleArrayData  name="PM 2.5">
            <gx:value>0.0</gx:value>
            <gx:value>-1.0001e+16</gx:value>
            <gx:value>180</gx:value>
        </gx:SimpleArrayData>
     </SchemaData>
    </ExtendedData>
   </gx:Track>
</Placemark>
</kml>

This is a shorter version of my actual full kml file


Solution

  • You are not using a correct format for the KML file

    Firstly, while this is correct for most cases

    <kml xmlns="http://www.opengis.net/kml/2.2">
    

    I prefer to use this (I forget why but I do)

    <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">
    

    but your main problem is you are also missing a <Document>

    so the actual file should look like this

    <?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>
    <name>Name</name>
    <Placemark>
    ...
    </Placemark>
    </Document>
    </kml>