Using KML Elements to Annotate Google Earth

Keyhole Markup Language (KML) is an XML-based standard used to display geographic data in mapping software like Google Earth. By utilizing a hierarchy of XML tags—most notably <Placemark>, <Point>, and <coordinates>—KML allows users to define specific locations, attach descriptive metadata, and render interactive visual pins on the virtual globe.

The <Placemark> Element

In KML, the <Placemark> element serves as the primary container for defining a map feature. It brings together the geographic geometry of an object with its identifying information. Within a <Placemark> tag, you typically include:

A Placemark does not define the visual position on its own; instead, it wraps around a geometry element, such as a Point, LineString, or Polygon.

The <Point> Element

To mark a single specific location on a map, the <Point> element is nested inside a <Placemark>. The <Point> tag informs Google Earth that the feature is a discrete, zero-dimensional geographic position rather than a path or an enclosed area.

When Google Earth reads a <Point> tag, it renders a standard pushpin or a custom icon at the designated position. The <Point> element can also include optional child tags like <altitudeMode> to specify whether the height should be relative to the ground, clamped to the surface, or absolute.

The <coordinates> Element

Nested directly within the <Point> tag is the <coordinates> element, which supplies the exact spatial data required to place the marker. KML strictly defines coordinate values in a specific order:

  1. Longitude: Expressed in decimal degrees (between -180 and 180).
  2. Latitude: Expressed in decimal degrees (between -90 and 90).
  3. Altitude (Optional): Expressed in meters above sea level.

Unlike common conversational usage where latitude is listed first, KML requires longitude, latitude, altitude separated by commas with no spaces between the numbers.

How Google Earth Interprets the XML Hierarchy

When Google Earth parses a KML file, it traverses the XML tree to construct the visual scene. The relationship between these elements is structured as follows:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Placemark>
    <name>Eiffel Tower</name>
    <description>Iconic iron lattice tower in Paris, France.</description>
    <Point>
      <coordinates>2.2945,48.8584,0</coordinates>
    </Point>
  </Placemark>
</kml>

When this file is opened, Google Earth reads the <coordinates> to calculate the precise spatial vector, builds a clickable pin defined by the <Point> geometry, and associates the label and pop-up data provided by the <Placemark>. Through this XML hierarchy, KML provides a standard, lightweight method for annotating geographic maps.