GPXParser.js is a JavaScript library designed for parsing .gpx (GPS Exchange Format) files, which are XML-based data structures for GPS information. It extracts core GPX data like metadata, waypoints, tracks, and routes, and further computes various derived metrics such as total and cumulative distances, minimum, maximum, average, positive, and negative elevation differences, and segment slopes. The current stable version is 3.0.8, actively maintained with regular patch releases addressing bug fixes and minor feature enhancements. A key differentiator is its ability to not only parse but also process the geographical data for insights, and export the parsed data into GeoJSON format, making it suitable for modern web mapping applications. It includes built-in polyfills for DOM functionalities, enabling its use in Node.js environments without manual setup since version 3.0.5.
npm install gpxparserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate GPXParser, parse a sample GPX string, access its metadata, tracks, and waypoints, and export the processed data to GeoJSON.
Review the official release notes and migration guides for gpxparser v3 to adapt your code. Re-test all GPX parsing and data access logic.
Upgrade to v3.0.5 or newer, which includes `jsdom-nogyp` as a dependency to provide these polyfills automatically. If upgrading isn't possible, manually include a DOM polyfill library.
Access documentation and demos directly from the project's GitHub repository (github.com/Luuka/GPXParser.js) rather than looking for them in `node_modules`.
Always use `import GPXParser from 'gpxparser';` for ESM and TypeScript, as GPXParser is a default export.
Ensure you are using `gpxparser` v3.0.5 or newer, which bundles necessary polyfills. If not, upgrade or manually provide a DOM polyfill like `jsdom`.
For ESM/TypeScript: `import GPXParser from 'gpxparser';` For CommonJS: `const GPXParser = require('gpxparser');` Then, `const gpx = new GPXParser();`.Always call `gpx.parse(gpxString)` with a valid GPX XML string before attempting to access parsed data properties. Add error handling around `parse()` if the input string might be invalid.
Change the import statement to use the default import syntax: `import GPXParser from 'gpxparser';`.