Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including gpx-builder with all npm packages installed. Try it out:

var gpxBuilder = require("gpx-builder")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gpx-builder v2.0.1

Builder of GPX files

GPX builder

codecov codecov codecov Maintainability

This library creates GPX files based on version 1.1. I recommend you to check full documentation on topografix. Library have also option to use Garmin extensions so you can add cadence, heart rate, speed and other data to your points.

How to use

Install:

npm install gpx-builder

Create your first GPX file:

const { buildGPX, GarminBuilder } = require('gpx-builder');

const { Point } = GarminBuilder.MODELS;

const points = [
    new Point(51.02832496166229, 15.515156626701355, {
        ele: 314.715,
        time: new Date('2018-06-10T17:29:35Z'),
        hr: 120,
    }),
    new Point(51.12832496166229, 15.615156626701355, {
        ele: 314.715,
        time: new Date('2018-06-10T17:39:35Z'),
        hr: 121,
    }),
];

const gpxData = new GarminBuilder();

gpxData.setSegmentPoints(points);

console.log(buildGPX(gpxData.toObject()));

How library works

Library contain two types of classes:

  • Creators - They create xml string from defined Object structure
  • Builders - They offer user friendly way to create data for creators

Library contain two Builders:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free