Keyhole Markup Language

From Helpful
Revision as of 01:28, 5 June 2010 by Helpful (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.

Note that KML is an open format, and specific apps (such as Google Earth) may not use/support all of it.

KML uses decimal lat-long, and uses WGS84. (always?(verify)) (see also Cartographic_notes)

Applications and associations

KML (Keyhole Markup Language)

  • MIME: application/

KMZ: KML-zipped

  • MIME:application/
  • containing a compressed KML file,
  • ...lets you pack in images (icons, etc.) so that the KML does not have to refer to public-server URIs for that

Will open in Google Earth or anything else that has it registered.

Note that Google Maps also takes KML, like:

Simple example

A simple KML file looks like: <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="">



What is stored

KML Features include:

  • Placemark (basic vector features: points, lines, polygons)
  • Folder, Document (containers)
    • Document (container for features and styles)
    • Folder (container for features)
  • image overlays (ground, screen, photo)
  • NetworkLink (to remote KML/KMZ files)

Note that Region is regularly used to describe metadata and points of interest within certain boxes.

Lod allows you to specify the (minimum, maximum) screen size of a feature before it should be considered active.


You can declare colors and/or line widths on icons, labels, lines, polygons, balloons, and lists.

May be ignored unless you need them.

Are usually referenced by their id, within the same document.

See also:


  • should include a <name> and
  • may include a <description> (HTML must be element-escaped, or in CDATA section)
  • may include a <LookAt> structure
  • may include a <styleUrl> to refer to style (usually a #hash based URL to refer to a style declared in the same KML file.
  • has an element declaring its type: (Point, LineString, etc., see below)
    • with option elements depending on the type
    • and a <coordinates> element
      • with coordinates in text nodes
      • space-separated coordinates
      • comma-separated per dimensions
        • longitude (≥ −180 and <= 180)
        • latitude (≥ −90 and ≤ 90)
        • altitude (meters) (optional)

Common options:

  • altitudeMode (string)
    • defines interpretation of the third (altitude) coordinate, if used:
    • clampToGround (default, ignores altitude)
    • relativeToGround: Relative to ground elevation
    • absolute: Relative to sea level (regardless of ground elevation)
  • extrude (boolean, 0 or 1)
    • connect point/line/polygon to ground (direction of center of Earth)
    • applies when altitudeMode is relativeToGround or absolute
  • tessellate (boolean, 0 or 1)
    • Show very large line segments so they follow the terrain (vertically, rather than poking through mountains, go underground, etc.)
    • applies when altitudeMode is clampToGround

Types, options per type

  • altitudeMode, extrude
  • Example: <Point><coordinates>-6.1456,-35.1</coordinates></Point>
  • Non-closed sequence of coordinates
  • altitudeMode, extrude, tessellate
  • Closed line string (a minimal polygon)
  • altitudeMode, extrude, tessellate,
  • typically the outer boundary of a Polygon. A LinearRing can also be used as the inner boundary of a Polygon to create holes in the Polygon. A Polygon can contain multiple <LinearRing> elements used as inner boundaries.
  • Similar to LinearRing, with a required main polygon, and contained cutout polygons:
    • outerBoundaryIs (LinearRing), required
    • innerBoundaryIs (LinearRing), (0 or more)
  • altitudeMode, extrude, tessellate


Can contain one or more Geometry-type (e.g. line, polygon) elements, that should be viewed as a single feature.

(except in cases where polygon innerBoundaries apply?)


Points to a COLLADA resource (see also Cartographic notes)

See Also

Time and animation:

Expiration, Updates: