
Interactive map with multiple GPX tracks in Leaflet
- Web developing
- November 25, 2026
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.
| Interaction | Map behaviour |
|---|---|
| Hover over a track | The route under the pointer is highlighted. |
| Click a track | A popup opens with a photo and route information. |
| Click another track | The visitor can inspect the new route in the same map view. |
| Follow a link in the popup | The 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
| Application | What the map can show |
|---|---|
| Hiking and trail running | Trails, loops, stages, and alternatives, with distance and elevation gain in the popup. |
| Mountain biking, gravel, and cycle touring | Routes with shared stretches, trailheads, access points, and transport information. |
| Caving | Surface approach tracks and entrance locations approved for public sharing. Underground passages require suitable cave surveys and visualisations. |
| Kayaking, sailing, and coastal activities | Indicative routes, links between landing points, and coastal itineraries. Navigation requires appropriate charts and tools. |
| Tourism and cultural trails | Themed 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.




















