Stay organized with collections Save and categorize content based on your preferences.
What is a KMZ File?A KMZ file consists of a main KML file and zero or more supporting files that are packaged using a Zip utility into one unit, called an archive. The KMZ file can then be stored and emailed as a single entity. A NetworkLink can fetch a KMZ file from a web server. When the KMZ file is unzipped, the main .kml file and its supporting files are separated into their original formats and directory structure, with their original filenames and extensions. In addition to being an archive format, the Zip format is also compressed, so an archive can include only a single large KML file. Depending on the content of the KML file, this process typically results in 10:1 compression. Your 10 Kbyte KML file can be served with a 1 Kbyte KMZ file.
Google Earth and Google Maps can read KML and KMZ files directly, and they can save files as KMZ files. By default, the main KML file is named doc.kml.
Note: For clarity, this page refers to the main KML file within a KMZ archive as doc.kml. This main KML file can have any name, as long as it ends in .kml, and as long as there is only one .kml file.
You should create a KMZ file if your doc.kml file is larger than 10 Kbytes, or if the doc.kml files references other files (images, sound files, models, textures).
Recommended Directory StructureThis section provides a few simple recommendations for the creators of KML/KMZ files. The example used in this section is from the Jimmy Buffett website, which uses the KML format to show planned concert tours and related highlights on Google Earth.
Download the KMZ file that contains this tour. (Used by permission.)
Note: Google Earth 6.0 strictly enforces the following set of guidelines when resolving relative references in a KMZ file (especially see item 4 in the following list). Earlier versions of Google Earth were less rigorous in how they resolved such relative references. As a result, some relative references that worked in Google Earth 5.2 and earlier releases may now need to be edited in order to work with versions 6.0 and later.
Follow these guidelines when creating KMZ files:
../myFavoritePlace.jpg
.For example, here is the file structure of the KMZ file for the Jimmy Buffett tour:
Since there are only five supporting files, they are all collected into a files subfolder within the main folder. If you load the file into Google Earth and then copy and paste it into a text browser, you'll see that all of the <href> elements use relative references to these supporting files (which represent icons, a screen overlay, and the sound file for the tour).
Here is the KML code for one of the icon references:
<IconStyle> <scale>1.1</scale> <Icon> <href>files/icon_surfing.png</href> </Icon> </IconStyle>
Here is the KML code for the reference to the sound file:
<gx:SoundCue> <href>files/Margaritaville.mp3</href> </gx:SoundCue>References to External Files
The doc.kml file usually contains a number of links to other files—images, icons, models, textures, and sound files. The references to these files are contained in the href attribute (or sometimes, the <href> element), which can be found in the following KML elements:
These external links can be either absolute or relative references, as described in the following section. They can refer to files within the same KMZ file, or to files contained in other KMZ files or stored elsewhere on the web. With the exception of the <sourceHref> element in <Model>, relative references are always resolved in relation to the doc.kml file, as explained in the section Resolving Relative References.
Absolute vs. Relative ReferencesAbsolute references contain the full URL for the linked file. They are useful for files posted on a central server and are unambiguous. However, if you use absolute references to local files, the links will break when the files are moved to a new system. Relative references avoid this problem.
Here is an example of an absolute reference to a file stored on a central server:
<Icon> <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href> </Icon>Resolving Relative References
In general, relative references are resolved in relation to the doc.kml file. Any relative URL is resolved against the directory that contains this file, which is considered the root of the KMZ file. In the Hawaiian tour example, the base URL is similar to the following (depending on where you download the KMZ file):
buffetthawaiitour.kmz
If you wanted to refer to a file located in a different KMZ file (for example, to images/jimmyphoto.jpg contained in margaritavillealbum.kmz, you would use the ".." notation to go up one level in the directory structure, which would take you out of the current KMZ file (buffetthawaiitour.kmz):
<href>../margaritavillealbum.kmz/images/jimmyphoto.jpg"</href>
Note: The rules for resolving relative references in a KMZ archive are based on the RFC 3986 Section 5 standard for resolving web URLs. The base URL is determined by the location of the doc.kml file, and all relative URLs are resolved in relation to that base URL.
The Exception: <sourceHref> in <Model>The <Model> element contains a <Link> element that specifies a COLLADA file to load into Google Earth. COLLADA files specify 3D objects and have a .dae file extension. The <Model> element also contains an <Alias> element, that contains a mapping between the <targetHref> (the texture file to be fetched by Google Earth) and the <sourceHref> (the path specified for the texture file in the COLLADA .dae file). If the <sourceHref> element contains a relative path, Google Earth interprets this path as relative to the .dae file that references it (not relative to the doc.kml file as in all other cases). For example:
<Model> . . . <Link> <href>MackyBldg.kmz/files/CU Macky.dae</href> </Link> <ResourceMap> <Alias> <sourceHref>../files/StairsnoCulling.jpg</sourceHref> <targetHref>../files/StairsnoCulling.jpg</targetHref> </Alias> <Alias> <sourceHref>../files/sideturretnoCulling.jpg</sourceHref> <targetHref>../files/sideturretnoCulling.jpg</targetHref> </Alias> . . . </Model>Creating the KMZ Archive
Use Windows Explorer or the Mac Finder to create a Zip archive. Select the contents of the folder that contains the doc.kml file and related resources and choose an option such as "WinZip > Add to Zip file ...." The Java JAR library also has a Zip library for programmatically creating and extracting a Zip archive, and Linux has command line versions of zip and unzip.
Note: When you are creating the Zip archive, be sure to select the contents of the folder containing the doc.kml file, not the folder itself.
After you create the archive, change the .zip file extension to .kmz. To extract the files from the archive, change the .kmz file extension back to .zip and use the Zip utility to unzip the archive.
Google Earth and KMZ Archives Use of the <iframe> ElementWithin KML <description> balloons, most HTML elements are treated in Google Earth just as they're treated in standard web browsers. An <iframe> within a description balloon, however, is treated as straight HTML, which means that special KML features are not recognized. For example, an <iframe> cannot display KMZ resources, and local anchor links, such as <a href="#my feature;flyto">
, are not recognized. The <src> element within an <iframe> element cannot point to a local file on disk, nor can it point to a file inside a KMZ file; it must point to a URL on the Internet that a browser can visit.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-11-03 UTC."],[[["A KMZ file is a compressed archive containing a main KML file (typically named doc.kml) and any supporting files like images or sounds."],["KMZ files are ideal for KML files larger than 10KB or those referencing external resources, offering efficient storage and sharing."],["When creating KMZ files, use relative paths for linked resources within the archive to ensure portability."],["Google Earth and Google Maps can directly read and save KMZ files, simplifying geospatial data handling."],["Within KMZ files, the `\u003ciframe\u003e` element is treated as straight HTML and has limitations regarding local file access and KML feature recognition."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4