# OpenLayers.Format.KML

Read/Write KML. Create a new instance with the OpenLayers.Format.KML constructor.

#### Inherits from

- OpenLayers.Format.XML

Summary

OpenLayers.Format.KML | Read/Write KML.
Properties |
kmlns | {String} KML Namespace to use.
placemarksDesc | {String} Name of the placemarks.
foldersName | {String} Name of the folders.
foldersDesc | {String} Description of the folders.
extractAttributes | {Boolean} Extract attributes from KML.
kvpAttributes | {Boolean} Only used if extractAttributes is true.
extractTracks | {Boolean} Extract gx:Track elements from Placemark elements.
trackAttributes | {Array} If extractTracks is true, points within gx:Track elements will be parsed as features with when, heading, tilt, and roll attributes.
maxDepth | {Integer} Maximum depth for recursive loading external KML URLs Defaults to 0: do no external fetching
Constructor |
OpenLayers.Format.KML | Create a new parser for KML.
Functions |
read | Read data from a string, and return a list of features.
write | Accept Feature Collection, and return a string.

### Properties

### kmlns

{String} KML Namespace to use. Defaults to 2.0 namespace.

### placemarksDesc

{String} Name of the placemarks. Default is “No description available”.

### foldersName

{String} Name of the folders. Default is “OpenLayers export”. If set to null, no name element will be created.

### foldersDesc

{String} Description of the folders. Default is “Exported on [date].” If set to null, no description element will be created.

### extractAttributes

{Boolean} Extract attributes from KML. Default is true. Extracting styleUrls requires this to be set to true Note that currently only Data and SimpleData elements are handled.

### kvpAttributes

{Boolean} Only used if extractAttributes is true. If set to true, attributes will be simple key-value pairs, compatible with other formats, Any displayName elements will be ignored. If set to false, attributes will be objects, retaining any displayName elements, but not compatible with other formats. Any CDATA in displayName will be read in as a string value. Default is false.

### extractTracks

{Boolean} Extract gx:Track elements from Placemark elements. Default is false. If true, features will be generated for all points in all gx:Track elements. Features will have a when (Date) attribute based on when elements in the track. If tracks include angle elements, features will have heading, tilt, and roll attributes. If track point coordinates have three values, features will have an altitude attribute with the third coordinate value.

### trackAttributes

{Array} If extractTracks is true, points within gx:Track elements will be parsed as features with when, heading, tilt, and roll attributes. Any additional attribute names can be provided in trackAttributes.

### maxDepth

{Integer} Maximum depth for recursive loading external KML URLs Defaults to 0: do no external fetching

### Constructor

### OpenLayers.Format.KML

Create a new parser for KML.

#### Parameters

options | {Object} An optional object whose properties will be set on this instance.

### Functions

### read

> read: function( | data | )

Read data from a string, and return a list of features.

#### Parameters

data | {String} or {DOMElement} data to read/parse.

#### Returns

{Array(OpenLayers.Feature.Vector)} List of features.

### write

> write: function( | features | )

Accept Feature Collection, and return a string.

#### Parameters

features | {Array(OpenLayers.Feature.Vector)} An array of features.

#### Returns

{String} A KML string.

{Boolean} Extract gx:Track elements from Placemark elements.

> read: function( | data | )

Read data from a string, and return a list of features.

> write: function( | features | )

Accept Feature Collection, and return a string.
Create a new parser for KML.
{Array} If extractTracks is true, points within gx:Track elements will be parsed as features with when, heading, tilt, and roll attributes.
Vector features use the OpenLayers.Geometry classes as geometry description.
Close