How to open kmz file online. What is the KMZ file extension? Handling relative links

What is a KMZ file?

A KMZ file includes the main KML file and, as a rule, associated resources, compressed using an archiver into a single archive. The KMZ archive can be stored on disk or sent by mail as a single file. Using the network link, the KMZ file can be obtained from the web server. Before compressing the main KML-the document and its associated resources are separate files with their own names and extensions, organized into directories. The KMZ format serves not only for archiving, but also for compression, so only one large KML file can be included in the archive. The file size can usually be reduced by a factor of ten (depending on the content). Thus, a 10 KB KML file can be turned into a 1 KB KMZ file.

Google Earth and Google Maps recognize KML and KMZ formats and also support saving KMZ files. By default, the main KML file is named doc.kml.

Note. For clarity, we will also call the main KML file in the KMZ archive doc.kml. In reality, it can be called anything, the main thing is that it must have an extension KML and be united KML-file in the archive.

If the file size doc.kml exceeds 10 KB or if it contains links to other resources (pictures, sound fragments, models or textures), you must create a KMZ archive.

This section contains some tips for creating KML and KMZ files. The example we're using comes from Jimmy Buffett's site, where the KML format is used to display tour itineraries and related information on Google Earth.

Download a KMZ file with information about this tour(used with permission of the owner).

Note. To ensure that relative links to KMZ files are processed correctly by Google Earth 6.0, you must follow all of the instructions below (pay particular attention to step 4). In earlier versions of the geobrowser, the rules for handling relative links were less strict, so some links that worked in Google Earth up to and including version 5.2 may not work in version 6.0 and later.

To create a KMZ file, follow these steps:

The example below shows the folder structure of the KMZ archive of Jimmy Buffett's tour.

Since there are only five additional files, they are all combined into a subfolder files. If you upload a file to Google Earth and then copy and paste the contents into a text editor, you will see that in all elements Relative links to additional resources (icons, screen overlays, sound files) are used.

1.1 files/icon_surfing.png

files/Margaritaville.mp3

Links to external files

In file doc.kml usually contains links to other files: pictures, icons, models, textures and sound fragments. They are included in the href attribute (or in the element ), which can be inside the following KML elements:

Links to external files can be absolute or relative– the next section is devoted to this. They can point to files inside the same KMZ archive, inside other KMZ archives, or on external web servers. Relative links are always determined based on the file location doc.kml, as described in the section. The only exception is inside element .

Absolute and relative links

An absolute link contains the entire URL of the file. Such links are unambiguous and, as a rule, point to files that are stored on external servers. An absolute link to a locally stored file will no longer work after it is moved to another system. To avoid this, it is recommended to use relative links.

http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png

Handling relative links

Relative links are processed based on the file location doc.kml, i.e. any relative path starts in the root folder of the KMZ archive. In the example above, the main URL looks like this (it may differ depending on where you downloaded the KMZ archive from):

Buffetthawaiitour.kmz

To link to a file located in another KMZ archive (for example, images/jimmyphoto.jpg V margaritavillealbum.kmz) the notation ".." is used, corresponding to moving one level up (exiting the current KMZ archive ( buffetthawaiitour.kmz).

../margaritavillealbum.kmz/images/jimmyphoto.jpg"

Note. The rules for processing relative links in the KMZ archive are based on the requirements of the RFC 3986 standard (Section 5). The main URL is determined by the file location doc.kml, and all relative URLs are processed based on it.

Exception: inside element

Element includes element , pointing to the COLLADA file to be uploaded to Google Earth. COLLADA files contain 3D models and have the extension DAE. Element also includes element , which connects (texture file transferred to Google Earth) and (path to texture file inside DAE-file). If in element a relative link is specified, Google Earth processes it based on the location of the DAE file, not doc.kml, as happens in all other cases. Let's look at an example.

. . . MackyBldg.kmz/files/CU Macky.dae ../files/StairsnoCulling.jpg ../files/StairsnoCulling.jpg ../files/sideturretnoCulling.jpg . . .

Creating a KMZ archive

To create a ZIP archive, use Windows Explorer or Mac Finder. Select the contents of the folder where the file is located doc.kml and related resources, and click WinZip > Add to ZIP File. The Java JAR library also contains a ZIP library for creating and extracting ZIP archives, and Linux provides corresponding command line instructions.

Note. When creating a ZIP archive, you need to select content file folders doc.kml, not the folder itself.

Change the extension of the created archive from ZIP on KMZ. If you need to extract the files, just change the extension again on ZIP, after which you can use a standard program for unpacking ZIP archives.

KMZ archives on Google Earth

Using the element