User Tools

Site Tools


kml

Table of Contents

KML

KML


version 2.2
KML is a file format used to display geographic data in an Earth browser such as Google Earth, Google Maps, and Google Maps for mobile. KML uses a tag-based structure with nested elements and attributes and is based on the XML standard.

Data Format

A Placemark is one of the most commonly used features in Google Earth. It marks a position on the Earth's surface, using a yellow pushpin as the icon. The simplest Placemark includes only a <Point> element, which specifies the location of the Placemark. You can specify a name and a custom icon for the Placemark, and you can also add other geometry elements to it.

Open the KML Samples file in Google Earth and expand the Placemarks subfolder. This folder includes three different types of placemark: simple, floating, and extruded.

The structure of this file breaks down as follows:

  • An XML header: This is line 1 in every KML file. No spaces or other characters can appear before this line.
  • A KML namespace declaration: This is line 2 in every KML 2.2 file.
  • A Placemark object that contains the following elements:
    • A name that is used as the label for the Placemark
    • A description that appears in the “balloon” attached to the Placemark
    • A Point that specifies the position of the Placemark on the Earth's surface (longitude, latitude, and optional altitude)

Example

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"><Document>

   <Style id="blue">
      <IconStyle>
         <Icon> 
           <href>http://maps.google.com/mapfiles/ms/icons/blue.png</href>
         </Icon>
      </IconStyle>
   </Style>

   <Placemark>
      <name>IconStyle.kml</name>
      <styleUrl>#blue</styleUrl>
      <Point>
         <coordinates>-122.36868,37.831145,0</coordinates>
      </Point>
   </Placemark>

   <Style id="blue-dot">
      <IconStyle>
         <Icon> 
           <href>http://maps.google.com/mapfiles/ms/icons/blue-dot.png</href>
         </Icon>
      </IconStyle>
   </Style>

   <Placemark>
      <name>IconStyle.kml</name>
      <styleUrl>#blue-dot</styleUrl>
      <Point>
         <coordinates>-123.36868,37.831145,0</coordinates>
      </Point>
   </Placemark>

</Document>
</kml>
kml.txt · Last modified: 2009/03/09 20:26 by heidi