Search code examples
kmlgoogle-earthkmz

Why is my NetworkLink not working inside a nested KMZ?


My problem is that I want to have a kmz file (nest1.kmz) nested within another kmz file (root.kmz) and also reference another nested .kml file (nest2.kml).

When I try to achieve this the network link that references the kml file does not load. enter image description here

The top answer for Nesting KMZ files makes it seem like it should hopefully be possible, so am I doing something wrong here?

root.kmz    >root.kml
            >[nest1]    >
                        >nest1.kmz  >
                                    >nest1.kml
                                    >[nest2]    >
                                                >nest2.kml

The code for the 3 files is as follows:

root.kml

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>root.kmz</name>
        <NetworkLink>
            <name>nest1.kmz</name>
            <Link>
                <href>nest1/nest1.kmz</href>
            </Link>
        </NetworkLink>
    </Document>
</kml>

nest1.kml

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>nest1.kmz</name>
        <NetworkLink>
            <name>nest2.kml</name>
            <Link>
                <href>nest2/nest2.kml</href>
            </Link>
        </NetworkLink>
            <Placemark>
                <Point>
                    <coordinates>175.589370309749,-39.5968230904137,0</coordinates>
                </Point>
            </Placemark>
    </Document>
</kml>

nest2.kml

<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
        <name>nest2.kml</name>
        <Placemark>
            <Point>
                <coordinates>176.589370309749,-39.5968230904137,0</coordinates>
            </Point>
        </Placemark>
    </Document>
</kml>

Solution

  • If you want a root KMZ file to reference other sub-KMZ files then the sub-KMZ files should not be sub-entries of the root KMZ file but located at the same relative context in the web server or file system.

    Google Earth supports a large number of nested KML files within a KMZ file but does NOT support nested KMZ files within a parent KMZ file. Either layout the content as file structure where 1) all sub-kml files are within a single root.kmz file, or 2) sub-kmz files are co-located with the root kml or kmz file.

    The file system or web server would have the following structures:

    Structure 1:

    root.kmz
      nest1/nested1.kml
      nest2/nested2.kml
    

    Structure 2:

    root.kmz
    nest1/nested1.kmz
    nest2/nested2.kmz
    

    root.kmz can refer to nest1/nested1.kmz and nested1.kmz can then reference nested2.kmz.

    Google Earth also supports sub-file references within a KMZ file so root.kmz could have a direct reference to nest2/nest2.kml if it is contained within nested1.kmz. That practice is not recommended since it may not be supported in applications other than Google Earth.

     <Link>
         <href>nested1.kmz/nest2/nested2.kml</href>
     </Link>