New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

gpx-parser-builder

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gpx-parser-builder

A simple gpx parser and builder between GPX string and JavaScript object

latest
Source
npmnpm
Version
1.2.0
Version published
Weekly downloads
652
-29.21%
Maintainers
1
Weekly downloads
 
Created
Source

gpx-parser-builder

A simple gpx parser and builder between GPX string and JavaScript object. It is dependent on fast-xml-parser.

npm GitHub stars GitHub forks npm GitHub license

Requirements

gpx-parser-builder is written with ECMAScript 6 and is now an ES Module.

Installation

npm install gpx-parser-builder --save

Usage

import GPX from 'gpx-parser-builder';

// Parse gpx
const gpx = GPX.parse('GPX_STRING');

window.console.dir(gpx.metadata);
window.console.dir(gpx.wpt);
window.console.dir(gpx.trk);

// Build gpx
window.console.log(gpx.toString());

Get more details about usage with the unit tests.

GPX

The GPX JavaScript object.

constructor(object)

const gpx = new Gpx({$:{...}, metadat: {...}, wpt:[{...},{...}]}, trk: {...}, rte: {...})

Member Variables

$ the attributes for the gpx element. Default value:

{
    'version': '1.1',
    'creator': 'gpx-parser-builder',
    'xmlns': 'http://www.topografix.com/GPX/1/1',
    'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
    'xsi:schemaLocation': 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'
}

metadata the metadata for the gpx.

wpt array of waypoints. It is corresponded to <wpt>. The type of all elements in wpt is Waypoint;

rte array of routes. It is corresponded to <rte>. The type of all elements in rte is Route;

trk array of tracks. It is corresponded to <trk>. The type of all elements in trk is Track;

Static Methods

parse(gpxString, options) parse gpx string to Gpx object. return null if parsing failed. The options is for fast-xml-parser's XMLParser.

Member Methods

toString(options) GPX object to gpx string. The options is for fast-xml-parser's XMLBuilder.

Save as GPX file in the frontend

You can leverage StreamSaver.js or FileSaver.js to save as GPX file. ⚠️Not all borwsers support the above file techniques. ⚠️️️

Author

Ke Zheng-Xiang, kf99916@gmail.com

License

gpx-parser-builder is available under the MIT license. See the LICENSE file for more info.

Keywords

gpx

FAQs

Package last updated on 09 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts