# OpenLayers.Format.GPX

Read/write GPX parser. Create a new instance with the OpenLayers.Format.GPX constructor.

#### Inherits from

- OpenLayers.Format.XML

Summary

OpenLayers.Format.GPX | Read/write GPX parser.
Properties |
defaultDesc | {String} Default description for the waypoints/tracks in the case where the feature has no “description” attribute.
extractWaypoints | {Boolean} Extract waypoints from GPX.
extractTracks | {Boolean} Extract tracks from GPX.
extractRoutes | {Boolean} Extract routes from GPX.
extractAttributes | {Boolean} Extract feature attributes from GPX.
namespaces | {Object} Mapping of namespace aliases to namespace URIs.
schemaLocation | {String} Schema location.
creator | {String} The creator attribute to be added to the written GPX files.
Constructor |
OpenLayers.Format.GPX | Create a new parser for GPX.
Functions |
read | Return a list of features from a GPX doc
extractSegment |
parseAttributes |
write | Accepts Feature Collection, and returns a string.
buildMetadataNode | Creates a “metadata” node.
buildFeatureNode | Accepts an OpenLayers.Feature.Vector, and builds a node for it.
buildTrkSegNode | Builds trkseg node(s) given a geometry
buildTrkPtNode | Builds a trkpt node given a point
buildWptNode | Builds a wpt node given a point
appendAttributesNode | Adds some attributes node.

### Properties

### defaultDesc

{String} Default description for the waypoints/tracks in the case where the feature has no “description” attribute. Default is “No description available”.

### extractWaypoints

{Boolean} Extract waypoints from GPX. (default: true)

### extractTracks

{Boolean} Extract tracks from GPX. (default: true)

### extractRoutes

{Boolean} Extract routes from GPX. (default: true)

### extractAttributes

{Boolean} Extract feature attributes from GPX. (default: true) NOTE: Attributes as part of extensions to the GPX standard may not be extracted.

### namespaces

{Object} Mapping of namespace aliases to namespace URIs.

### schemaLocation

{String} Schema location. Defaults to “http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd”

### creator

{String} The creator attribute to be added to the written GPX files. Defaults to “OpenLayers”

### Constructor

### OpenLayers.Format.GPX

Create a new parser for GPX.

#### Parameters

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

### Functions

### read

> read: function( | doc | )

Return a list of features from a GPX doc

#### Parameters

doc | {Element}

#### Returns

Array({OpenLayers.Feature.Vector})

### extractSegment

> extractSegment: function( | segment,
> | segmentType | )

#### Parameters

segment | {DOMElement} a trkseg or rte node to parse
segmentType | {String} nodeName of waypoints that form the line

#### Returns

{OpenLayers.Geometry.LineString} A linestring geometry

### parseAttributes

> parseAttributes: function( | node | )

#### Parameters

node | {<DOMElement>}

#### Returns

{Object} An attributes object.

### write

> write: function( | features,
> | metadata | )

Accepts Feature Collection, and returns a string.

#### Parameters

features | {Array(OpenLayers.Feature.Vector)} List of features to serialize into a string.
metadata | {Object} A key/value pairs object to build a metadata node to add to the gpx. Supported keys are ‘name’, ‘desc’, ‘author’.

### buildMetadataNode

> buildMetadataNode: function( | metadata | )

Creates a “metadata” node.

#### Returns

{DOMElement}

### buildFeatureNode

> buildFeatureNode: function( | feature | )

Accepts an OpenLayers.Feature.Vector, and builds a node for it.

#### Parameters

feature | {OpenLayers.Feature.Vector}

#### Returns

{DOMElement} | The created node, either a ‘wpt’ or a ‘trk’.

### buildTrkSegNode

> buildTrkSegNode: function( | geometry | )

Builds trkseg node(s) given a geometry

#### Parameters

trknode geometry - {OpenLayers.Geometry}

### buildTrkPtNode

> buildTrkPtNode: function( | point | )

Builds a trkpt node given a point

#### Parameters

point | {OpenLayers.Geometry.Point}

#### Returns

{DOMElement} A trkpt node

### buildWptNode

> buildWptNode: function( | geometry | )

Builds a wpt node given a point

#### Parameters

geometry | {OpenLayers.Geometry.Point}

#### Returns

{DOMElement} A wpt node

### appendAttributesNode

> appendAttributesNode: function( | node,
> | feature | )

Adds some attributes node.

#### Parameters

node | {DOMElement} the node to append the attribute nodes to.
feature | {OpenLayers.Feature.Vector}

> read: function( | doc | )

Return a list of features from a GPX doc

> extractSegment: function( | segment,
> | segmentType | )

> parseAttributes: function( | node | )

> write: function( | features,
> | metadata | )

Accepts Feature Collection, and returns a string.

> buildMetadataNode: function( | metadata | )

Creates a “metadata” node.

> buildFeatureNode: function( | feature | )

Accepts an OpenLayers.Feature.Vector, and builds a node for it.
Vector features use the OpenLayers.Geometry classes as geometry description.

> buildTrkSegNode: function( | geometry | )

Builds trkseg node(s) given a geometry

> buildTrkPtNode: function( | point | )

Builds a trkpt node given a point

> buildWptNode: function( | geometry | )

Builds a wpt node given a point

> appendAttributesNode: function( | node,
> | feature | )

Adds some attributes node.
Create a new parser for GPX.
A LineString is a Curve which, once two points have been added to it, can never be less than two points long.
A Geometry is a description of a geographic object.
Point geometry class.
Close