Interactive map with multiple GPX tracks in Leaflet Elementor text alignment not working? Trace the CSS conflict Forms, search and bookings: adding static website features Migrating Joomla to a static website: content, menus and SEO Migrating WordPress to a static website: benefits and SEO checks Static website hosting and maintenance: costs and management Static website SEO: content, indexing and performance Updating an HTML website with AI: a practical review process Static HTML and CSS websites: a new lease of life with AI Why Joomla deserves to be the best CMS choice for corporate and business projects—and beyond How to create a Joomla 6 module with YOOtheme Builder Emails going to spam: setting up SPF, DKIM and DMARC Joomla on LiteSpeed: CSS and JavaScript 403 errors with query strings Joomla 3 to Joomla 6 with T3 and Purity III: a migration case study Website hacked? What to do first and mistakes to avoid Interactive map with multiple GPX tracks in Leaflet Elementor text alignment not working? Trace the CSS conflict Forms, search and bookings: adding static website features Migrating Joomla to a static website: content, menus and SEO Migrating WordPress to a static website: benefits and SEO checks Static website hosting and maintenance: costs and management Static website SEO: content, indexing and performance Updating an HTML website with AI: a practical review process Static HTML and CSS websites: a new lease of life with AI Why Joomla deserves to be the best CMS choice for corporate and business projects—and beyond How to create a Joomla 6 module with YOOtheme Builder Emails going to spam: setting up SPF, DKIM and DMARC Joomla on LiteSpeed: CSS and JavaScript 403 errors with query strings Joomla 3 to Joomla 6 with T3 and Purity III: a migration case study Website hacked? What to do first and mistakes to avoid
Interactive map with multiple GPX tracks in Leaflet

Interactive map with multiple GPX tracks in Leaflet

Author Graziano De Maio - Gdmtech
I wish you a good read and remember: if after reading this article you need help, don't hesitate to contact me.
Author: Graziano De Maio | Founder of Gdmtech
Table of contents

I built an interactive map with multiple GPX tracks for a client using Leaflet. All the routes are visible at once. Hovering over a track highlights it, and clicking the line opens a popup with a photograph and route information on the map.

Visitors can switch between routes and compare them in the same map view. Once they choose a route, they can download the GPX file or open the full route guide from the popup. You can try this interaction on the Livigno mountain bike route map.

How to display multiple GPX tracks on a map with Leaflet

GPX is an XML format that can contain tracks, routes, and waypoints. A track contains one or more segments, each made up of an ordered sequence of geographic points. On a web map, those points can be drawn as a polyline, a series of connected line segments.

Leaflet handles map rendering and interaction. Reading the GPX is a separate step that extracts the coordinates and passes them to the library. Leaflet provides L.polyline to draw the track, setStyle to change its appearance, and bindPopup to associate a popup with the geometry.

Each route in the project can be selected independently within the shared map. Its geometry determines where the line appears. The information associated with the route determines what the popup displays and where its links lead. A photograph and a route guide link can therefore accompany the track as editorial content.

How an interactive map with clickable routes works

Colour helps distinguish routes, but following a line can be difficult where tracks cross. Hover highlighting gives visitors immediate feedback about which route will open when they click. The line itself acts as the control for selecting the route.

InteractionMap behaviour
Hover over a trackThe route under the pointer is highlighted.
Click a trackA popup opens with a photo and route information.
Click another trackThe visitor can inspect the new route in the same map view.
Follow a link in the popupThe visitor opens the route guide or downloads the GPX file.

Exact overlaps require special attention. When two routes share the same coordinates, a pointer event may reach only one of the lines. A synced route list or a selector for routes at that location can help visitors reach the other route. A list can also provide a keyboard-accessible way to choose an itinerary. On touchscreens, direct tap selection can provide access to the popup without a hover state.

What the route popup shows and how GPX downloads work

The project screenshot shows a photo, the route name, a logistics note, the distance, and the elevation gain. Two links offer separate actions for reading the full description and downloading the GPX file.

The map shows where a track goes and how it relates to nearby routes. The popup adds the information a visitor needs to compare options. Two rides that start close together, for example, can differ considerably in distance, climbing, or transport requirements.

For larger route catalogues, consistent fields, units, and data sources help keep those comparisons meaningful. A distance calculated from track coordinates and an elevation gain taken from an editorial route guide can have different sources worth recording in the catalogue. Point density and the available elevation data also affect measurements derived from the track. For more on the format, see the guide to GPX files with and without timestamps.

Interactive maps for tourist routes, hiking, and MTB

ApplicationWhat the map can show
Hiking and trail runningTrails, loops, stages, and alternatives, with distance and elevation gain in the popup.
Mountain biking, gravel, and cycle touringRoutes with shared stretches, trailheads, access points, and transport information.
CavingSurface approach tracks and entrance locations approved for public sharing. Underground passages require suitable cave surveys and visualisations.
Kayaking, sailing, and coastal activitiesIndicative routes, links between landing points, and coastal itineraries. Navigation requires appropriate charts and tools.
Tourism and cultural trailsThemed routes, multi-stage walks, and circuits linking several places, with links to individual guides.

Tourism organisations can use an interactive route map to bring itineraries and guides from several destinations together on one page. This approach fits catalogues where the shape of a route helps people make a decision. Seeing the full line makes it easier to understand which alternatives pass through an area or share a stretch.

Integrating a GPX map into a website with a large route catalogue

Browser workload depends on both the number of routes and the number of points in their geometries. A handful of detailed tracks can require more work to render than a larger set of simpler ones. Photos and popup content can also affect initial load time if the page requests them all at once.

For a larger catalogue, one option is to draw a simplified geometry in the browser and keep the original GPX available for download. Filters by area or activity can help when the map becomes crowded. Which approach fits depends on how many routes need to appear together and the level of detail visitors need at the map scales they use.

If you need a custom interactive map for your website, contact me. I can review your GPX files and build a Leaflet map that connects them to your existing route pages and downloads.

Author Graziano De Maio - Gdmtech
I wish you a good read and remember: if after reading this article you need help, don't hesitate to contact me.
Author: Graziano De Maio | Founder of Gdmtech