FC
Francesco Castaldi
Development

Building a GPX Editor in TypeScript and Leaflet

DATE: 2025-09-20|READ TIME: 3 MINS|AUTHOR: FRANCESCO CASTALDI
Architecture of the GPX Editor
FIG: Architecture of the GPX Editor

Why a GPX Editor in the Browser?

Cyclists and runners accumulate gigabytes of GPX files from their Garmin or Wahoo devices. Often, these files contain speed spikes or power data errors. Until yesterday, to clean these tracks, you had to download heavy desktop software. The challenge? Creating a 100% web-based editor. Zero backend. Zero uploads to slow servers.

What we will build: - Client-side parsing of GPX files - Smoothing algorithm to clean data - Interactive elevation profile with Chart.js

Core Features and Architecture

All the magic happens on the client. Your GPX file never leaves your computer.

1. Reading and Parsing: Instant reading of the XML. 2. Smoothing (Douglas-Peucker): An essential algorithm that simplifies the track by eliminating redundant GPS points, saving the path shape while drastically reducing file size. 3. Elevation Profile: Rendered at 60fps using Chart.js, offering immediate visual feedback on the slope.

[ IMPORTANT ]
Keeping everything on the client means Total Privacy for users. No one wants their home coordinates to end up on an unknown server.

Technological Choices

To build the application, a lean and type-safe stack was needed.

TechnologyRoleMotivation
TypeScriptCore LogicTo manipulate coordinates and XML you need strong typing, otherwise geospatial bugs are endless.
LeafletMap RenderingMuch lighter than Mapbox GL and with a permissive license (BSD).
Chart.jsElevationSimple API, performant Canvas for datasets of thousands of points.
ViteBundlerInstant HMR, essential for iterating UI quickly.

*Table 1: Tech Stack for the GPX Editor*

// Simplified GPX parsing example
import { DOMParser } from "xmldom";
const doc = new DOMParser().parseFromString(gpxString, "text/xml");
const trkpts = doc.getElementsByTagName("trkpt");
console.log(`Found ${trkpts.length} points in the track`);

The final result is a professional, fluid, and secure tool, accessible from any modern browser.

[ ← Back to Articles ][ Back to Home → ]
[ FC.SYS // ENG ]
GitHub|LinkedIn|Email
FRANCESCO CASTALDI © 2026