Combining Multiple KML files into one KMZ file [Bug]

3,606 views
Skip to first unread message

netfire

unread,
Mar 18, 2011, 7:25:22 PM3/18/11
to KML Developer Support - Advanced Support for KML
I've been working on a project to combine multiple kml files into a
single kmz file. In doing so, I had problems getting Google Earth to
read the doc.kml file within the main kml (it was reading one of the
kml files within the sub-folders instead). It turns out that the way I
was zipping the kml was putting the doc.kml file at the end of the
main directory listing. Changing the zip order to make the the doc.kml
be the first file fixed the problem. So using the command-line zip
utility in linux:

zip -r file.kmz kmls/ doc.xml

does not work, while

zip -r file.kmz doc.xml kmls/

does work.

It seems that Google Earth is not only looking in the top-level
directory for the first .kml file, as stated in the documentation, but
looks in the sub-folders as well, doing so before looking at the rest
of the top-level directory files.

Here's the doc reference:

http://code.google.com/apis/kml/documentation/kmzarchives.html

netfire

unread,
Mar 18, 2011, 7:33:20 PM3/18/11
to KML Developer Support - Advanced Support for KML
that second line should be:

zip -r file.kmz doc.kml kmls/

Rossko

unread,
Mar 19, 2011, 3:50:33 PM3/19/11
to KML Developer Support - Advanced Support for KML
> It seems that Google Earth is not only looking in the top-level
> directory for the first .kml file, as stated in the documentation, but
> looks in the sub-folders as well, doing so before looking at the rest
> of the top-level directory files.

"If the archive contains multiple .kml files, you cannot be sure which
one will be found first, so you need to include only one"
seems to be clear enough ?

netfire

unread,
Mar 21, 2011, 4:03:11 PM3/21/11
to KML Developer Support - Advanced Support for KML
A KMZ file can include multiple KML files, but those files should be
contained in subfolders. The KMZ file in this case is combining
multiple KML files together. The problem is that Google Earth is
finding a KML in the subfolder before finding one in the top-level
directory.

JanaHlava

unread,
Mar 21, 2011, 5:20:36 PM3/21/11
to KML Developer Support - Advanced Support for KML
I have the same problem:
http://code.google.com/p/earth-api-samples/issues/detail?id=591

Is Google going to do something about this bug???

Jason M

unread,
Mar 28, 2011, 10:38:14 PM3/28/11
to KML Developer Support - Advanced Support for KML
Hi,

Whether the .kml files are in sub-folders or not doesn't matter.
What Google Earth does is simply open the first entry in KMZ file that
ends with .kml extension regardless of it being at the root level or a
sub-folder.

The parent KML file at the root level (typically named doc.kml) is a
convention -- not mandatory.

So you must always add the root KML file *first* then the other kml
files (and images) as was used in the order that worked:
Reply all
Reply to author
Forward
0 new messages