KMZ Files  |  Keyhole Markup Language  |  Google for Developers (2024)

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 Structure

This 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.

KMZ Files | Keyhole Markup Language | Google for Developers (1)

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:

  1. Create a folder that will contain the contents of your KMZ file. Give it a descriptive name (for example, buffetthawaiitour).
  2. Put the default KML file (doc.kml, or whatever name you want to give it) at the top level within this folder. Include only one .kml file. (When Google Earth opens a KMZ file, it scans the file, looking for the first .kml file in this list. It ignores all subsequent .kml files, if any, in the archive. If the archive contains multiple .kml files, you cannot be sure which one will be found first, so you need to include only one.)
  3. Include one or more subfolders within the main folder to collect images, models, textures, sound files, or other resources referenced in the doc.kml file. The complexity of this directory structure depends on the number of supporting files and your preferences for organization.
  4. Use relative references. See References to External Files for more details. All relative paths begin inside the base folder described above in item 1. For example, if a KMZ file vacationJournal.kmz is on the desktop, and its doc.kml file refers to a file myFavoritePlace.jpg, which is also on the desktop, the <href> in the doc.kml file is ../myFavoritePlace.jpg.
  5. Do not use the .kmz extension for any of the subfolders within a KMZ file. The .kmz extension is reserved for the name of the archive itself.
    1. For example, here is the file structure of the KMZ file for the Jimmy Buffett tour:

      KMZ Files | Keyhole Markup Language | Google for Developers (2)

      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:

  • the <a href> element of a <description> (and also <img src> in a <description>)
  • <Icon> (as a child of <IconStyle>, <GroundOverlay>, <ScreenOverlay>, <PhotoOverlay>)
  • <ItemIcon>
  • <Link>
  • <gx:SoundCue>
  • <targetHref> and <sourceHref> in <Alias>

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 References

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

KMZ Files | Keyhole Markup Language | Google for Developers (3)

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

Within 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.

KMZ Files  |  Keyhole Markup Language  |  Google for Developers (2024)

FAQs

Is KML a markup language? ›

KML (formerly known as Keyhole Markup Language) is an XML-based file format for displaying information in a geographic context. KML information can be drawn in many earth-based browsers, including ArcGIS Earth and ArcGIS Pro. KML Version 2.2 has been adopted as an Open Geospatial Consortium (OGC) standard.

Can Google Earth read KMZ files? ›

If you have a KML or KMZ file from an older version of Google Earth, you can open it in Google Earth. At the top, tap Open. To add a file directly from your device, tap Import KML File. To select a file from your Google Drive or a shared file, tap Open project from Drive.

How do I edit KMZ lines in Google Earth? ›

To edit a KMZ file, you can open it in Google Earth, right-click it in the Places Pane, choose Copy from the menu, and paste the contents into a text editor.

How do you markup on Google Earth? ›

Mark map locations with placemarks
  1. On your computer, open Google Earth.
  2. Navigate to the place you want to save.
  3. Above the map, click Add Placemark .
  4. In the new window, next to "Name," enter a placemark name.
  5. To choose a different placemark icon, to the right of the "Name" field, click the button.

What is the difference between KML and KMZ? ›

The main difference lies in their level of compression. KML is an uncompressed file format while KMZ (Keyhole Markup Language Zipped) is the compressed version of a KML file.

What is the content type of KMZ file? ›

kmz extension. The contents of a KMZ file are a single root KML document (notionally "doc. kml") and optionally any overlays, images, icons, and COLLADA 3D models referenced in the KML including network-linked KML files. The root KML document by convention is a file named "doc.

What program opens a 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.

Can I import a KMZ file into Google Maps? ›

Include Kml/Kmz file

Step 1 Go to Add or Edit Map page and scroll down to 'Layers Settings' section. Step 2 Mark checked Kml/Kmz Layer option. Step 3 Enter the full URL to the KML file you uploaded. You can display multiple kml layers on google maps by inserting comma(,) separated kml urls.

Can you edit KML in Google Earth? ›

You can make changes to, share, or delete KML files and projects saved to Google Drive in Google Earth. You can also collaborate with multiple users to edit your project via Google Drive. Tip: Projects on Google Earth can be viewed, but not created, on your mobile devices. On your computer, open Google Earth.

How to open KMZ file in notepad++? ›

Notepad++ is a text editor. So because KMZ is a ZIP file format, it cannot be opened directly by Notepad++. If you want to compare the extracted KML files in XML format, you have to install the Compare extension in Notepad++ from the main menu. One simple solution to my problem that I have seems similar to yours.

How do I mark a route on Google Earth? ›

Draw a path or polygon
  1. Open Google Earth.
  2. Go to a place on the map.
  3. Above the map, click Add Path or polygon .
  4. To draw the line or shape you want, click a start point on the map and drag.
  5. Click an endpoint.
  6. Click Done.

How do you draw and write on Google Earth? ›

Draw a line or shape
  1. On your computer, sign in to My Maps.
  2. Open or create a map. ...
  3. Click Draw a line. ...
  4. Select a layer and click where to start drawing. ...
  5. Click each corner or bend of your line or shape. ...
  6. When you're finished drawing, double-click or complete the shape.
  7. Give your line or shape a name.

How do I add an annotation in Google Earth? ›

To edit a polygon's location, name, or description, right-click on the path in the 3D viewer or in the Places panel, and choose Properties (on a PC) or Get Info (on a Mac). Then you can edit the title and description and click OK.

Is XML a markup language or not? ›

Extensible Markup Language (XML) is a markup language that provides rules to define any data. Unlike other programming languages, XML cannot perform computing operations by itself. Instead, any programming language or software can be implemented for structured data management.

What language is considered to be a markup language? ›

Some examples of markup languages include hypertext markup language (HTML), extensible markup language (XML), and Markdown. HTML is widely used for creating web pages, XML is used for data storage and exchange, and Markdown is popular for creating structured documents with plain text formatting.

Is CSV a markup language? ›

CSV is used for storing and exchanging data. Markdown is human-friendly markup language, which can be automatically translated to HTML. They are quite different, but you can easily convert CSV to Markdown with Easy Data Transform: Install Easy Data Transform on your PC or Mac, if you haven't done so already.

Is PHP is a markup language? ›

HTML is a markup language used for creating static web pages, whereas PHP is a server-side scripting language used for creating dynamic web pages. HTML defines the structure and content of a web page, while PHP allows you to interact with a database and generate dynamic content.

Top Articles
Electronic Federal Tax Payment System
Atomic Wallet
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Pearson Correlation Coefficient
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated:

Views: 6696

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.