Explore Teaching Examples | Provide Feedback

KML Examples from the Google Earth Community Forums

Initial Publication Date: December 1, 2008

An effective means of learning about KML is to open existing KML files in Google Earth to find out how they function, and then to examine the content of these files in a text editor to investigate how that functionality was implemented. Follow this up with some experimentation by editing the file in the text editor, saving it, and reloading it again into Google Earth.

A good place to learn more about KML and KMZ files is KML Tutorial. Another place to become more expert with Google Earth is Google Earth Outreach's Learn Site.

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. In some cases, though, if the KMZ archive contains images or other locally-referenced files, this method will adjust some of the code based on the configuration of the local client machine. To guarantee that the original KML will remain intact, download the KMZ file and change the filename extension from kmz to zip. Then extract all the files and look for the KML in the doc.kml file. Following is a discussion of some examples of KML from the Google Earth Community Forums. The displayed KML code does not include the complete contents of the example files. To view the examples in Google Earth, use the attachments to the actual posts in the Forums.

2020 Update: the following links to files do not work because the original Google Earth Community Forums have been discontinued but the information about working with KML files is still helpful.

Lighthouses on Novaya Zemlya? by diane9247 - Simple Placemarks

This post with its attachment initiated an interesting discussion about lighthouses that a member of the Google Earth Community noticed on the imagery for remote Novaya Zemlya.

Novaya Zemlya
Lighthouse Placemarks on the imagery for Novaya Zemlya


Below is the KML for the Placemark for Light F

Light F
This one looks taller than the others and is more obviously an open framework tower.
See post for the collection.




The Placemark element contains the following elements:

  • name - This serves as a label for the Placemark in the 3D Viewer and in the Places Pane. It also appears at the top of the information balloon for the Placemark.
  • description - This appears in the information balloon for the Placemark.
  • LookAt - This determines the initial view of the Placemark when it is double-clicked in the Places Pane of the 3D Viewer.
  • styleUrl - This refers to the StyleMap defined in the Document element that contains the Folders and Placemarks in this file. The StyleMap specifies what Style elements apply to the Placemark in normal and highlight modes.
  • Point - This is the geographic location of the placermark icon.

Names of elements in KML are case sensitive. Elements that can contain other elements are called complex elements, and their names begin with uppercase letters. Simple elements are ones that cannot contain other elements, and their names begin with lowercase letters.

San Andreas Fault Tour, 88 Places by rocdoc7 - Placemarks in a Folder for a Tour


The KMZ file attachment to this post is designed to offer a tour of the San Andreas Fault. With the file open in Google Earth, highlight the Folder that contains the Placemarks. Then click the Start Tour button. Note that the tour visits the Placemarks in order from south to north with an oblique view of each.

San Andreas Fault Tour
San Andreas Fault Tour


Following is some of the KML from the file, showing only the first three and last Placemarks. They are listed in order from south to north.

San Andreas fault tour

south end, Imperial Valley 1




lines in the hills 2




I-10 crossing 3





Point Delgada, last north exposure 88




Note that each Placemark element contains a LookAt element. This controls the characteristics of the User's initial viewPoint of the location during the tour. The longitude and latitude do not always match the ones in the coordinates element but are generally close. In these Placemarks, the tilt is oblique. A 90 degree tilt would be straight down, but the oblique view affords a better look along the length of the fault.

Moore in America by SandyRichard - Placemarks with Custom Icons and Flickr Photos

Moore in America Exhibition
Moore in America


This post focuses on the Moore in America outdoor exhibition at the New York Botanical Garden. Two portions of the KML code are shown below.



<br> <IconStyle><br> <scale>1.3</scale><br> <Icon><br> <href>files/MoreMoore1.png</href><br> </Icon><br> </IconStyle><br>
<br> <IconStyle><br> <scale>1.1</scale><br> <Icon><br> <href>files/MoreMoore1.png</href><br> </Icon><br> </IconStyle><br>

In the first portion of the KML code, one StyleMap and two Style elements are defined. The StyleMap Pairs the two styles together in preparation for one style to apply to the Placemark icons on the map while they are not highlighted and the other style to apply when one is highlighted by a mouseover. Within each portion of the Pair, these roles are specified by the key element.

Large Reclining Figure (#7)




This Placemark contains a styleUrl element that applies the StyleMap shown above to the Placemark. Within the description element, a url for an image of a sculpture is specified, surrounded by a hyperlink to its photo page on Flickr.

Positively 4th Street by JavaGAR - Paths

Positively 4th Street
Lower Manhattan


This post has a KMZ attachment that displays Points and Paths on the map to represent several streets. The KML for the Path that represents Bleecker Street is shown below.

Bleecker Street





The Path for Bleecker Street is implemented as a Placemark with LineString element. Within the LineString element are a tesselate and a coordinates element. With the value of the tessellate element set to 1, the Path will be fit to the curvature of the Earth, so that parts of it do not become hidden below ground. The coordinates element specifies the vertices of the Path, with each vertex represented by a set of three comma-delimited values, called a tuple. These values are longitude, latitude, and altitude respectively. As is the default, the latitude, which is zero in all these tuples, is given relative to ground level.

Long Island Pine Barrens by JavaGAR - Polygons

Long Island Pine Barrens
Long Island Pine Barrens

On this map, conservation zones within the Long Island Pine Barrens are bounded by Polygons. Part of the KML for one of the Polygons is shown below.




This Polygon has a hole in it, so it has both an outer boundary and an inner boundary. The outerBoundaryIs and innerBoundaryIs elements each contain LinearRing elements, which in turn contain coordinates elements that list the vertices of the respective boundaries. In each of these lists of coordinates, the first and last tuple match so that the shape is closed.

World Oil Consumption by giasen - Extruded Polygons

World Oil Consumption
World oil consumption by country with prisms


The KMZ attachment to this post represents each country of the world with a three-dimensional prism. These prisms are actually elevated Polygon elements that are extended down to the ground. The height of the prism is proportional to the total oil consumption for that country represented as foot height per barrel per day divided by 10 to keep it from shooting off the screen according to CIA Factbook. The replies to the post include commentary on the effectiveness of this strategy for representing oil consumption. Several other possible methods are suggested among these comments.





The part of the KML for one Polygon that is shown here outlines the 48 contiguous states of the United States. The value of its extrude element is 1, meaning that it will be extended to the ground, making it into a prism. The altitudeMode is set to relativeToGround, meaning that all altitudes, which are given in meters, will be added to the elevations of the Points at which they are given to determine the absolute altitude of that vertex of the prism. The value of the coordinates element is a set of tuples that represent longitude, latitude, and altitude. Each tuple is separated from its neighbors by a whitespace. Only the first, second, and last tuples are shown here. Note that the last one is identical to the first one, which neatly closes the Polygon. For this Polygon, the altitudes are set to 6318504.078090191, which is the elevation of the upper surface of the prism representing the oil consumption of the United States.

Sumatra-Andaman Earthquake+Tsunami overlays by Georggpd - Image Overlay

Banda Aceh Overlay
Image overlay of Banda Aceh prior to the tsunami of December 26, 2004

The KMZ file attached to this post contains overlays pertaining to the Boxing Day Tsunami, which occurred in the Indian Ocean on December 26, 2004. The KML below is for the overlay of aerial imagery of Banda Aceh prior to the event. 

Banda Aceh before

images/Banda Ache before.JPG


The LatLonBox element specifies the bounds of the overlay and the counterclockwise rotation in degrees needed to align it properly.

RUSSIA TOWER, 3D model, Norman Foster Proposal. by pivnice - 3D Model


The KMZ file attached to this post represents a 3D model composed of numerous parts. The content is divided into Folders. The first Folder can be double-clicked to provide a view of the model. Following is the KML:




3D Model of Proposed Tower in Russia
Tower Model


The model itself contains many Polygon and LineString elements within MultiGeometry elements. A portion of one of the MultiGeometry elements follows:






Education Tools. Assembling. by Valery35 - Network Link

Marine Biomes
Marine Biomes educational data from a network link

The KMZ attachment to this post is a collection of network links to popular collections of data from the Education forums of the Google Earth Community. A network link references data that is not downloaded until the user makes the network link visible by activating its checkbox in the Places Pane. The KML below is for a network link in the attachment that references data from a Google Earth Community Forums post on Marine Biomes. The href element specifies where the data resides that is downloaded when the network link is activated, and in this case it links to the attachment on the Marine Biomes post. 

Marine Biomes


Mt. St. Helens - Web Cam Time-lapse by pmaxfield2 - TimeStamp

Mount Saint Helens
Mount Saint Helens screen overlays with time slider

This example uses TimeStamp elements within ScreenOverlay elements to display a sequence of photographs of a minor eruption of Mount Saint Helens that occurred in 2004. The time slider controls the visibility of the photographs provided that their visibility checkboxes are checked in the Places Pane. Each ScreenOverlay represents one photograph. ScreenOverlays are connected to a fixed location on the screen even when the map view changes. Below is shown the KML for two of the overlays. The KMZ file attached to the Google Earth Community post contains a doc.kml file and a files Folder. The image files are contained in the files Folder. These images are referenced in the href elements. 

 StHelens - 01
 files/Helens 20041001-1154.jpg
 StHelens - 02
 files/Helens 20041001-1159.jpg

UFO Sightings - Time Animation by Frank4

UFO Sightings
This map of UFO reports has a timeline. Here is is shown on Google Earth 4.2, which is why the navigation controls are different from those pictured in the other examples.


This is an interesting example of the use of the Google Earth time slider that maps UFO reports through time. TimeStamp elements from three of the PlaceMarks are shown below. Note that the time can be a date without a time of day. In fact, it can consist of only a year or a year and a month.

1948-05-10 ..... 1954-06 ..... TimeStamp>1944 .....

For additional information on KML, see Google's What is KML?

The New KML Interactive Sampler is a good collection of sample code.