3D GPX courses
<wodira-route-3d> draws a GPX course over 3D terrain and satellite imagery. Its elevation profile responds to mouse, touch and keyboard; visitors can also fly over the course, switch to 2D and use full screen.
Visual example
Section titled “Visual example”<wodira-route-3d>Interactive sampleExplore the GPX course, move over its elevation profile and try the flythrough, 2D view or full screen. The sample file is served by this site; map tiles come from external providers.
The illustrative Ibiza sample is not an official navigation route. The GPX is hosted by docs and requires no account or API key. Terrain and satellite tiles come from external providers, with attribution visible on the map.
Installation
Section titled “Installation”Included in the source of the upcoming 1.2.0 release, not yet published on npm. This page uses the monorepo package; install the published version when available or build the source yourself.
import { defineWodiraRouteElements } from '@wodira/browser/ui/route-3d';
defineWodiraRouteElements();<wodira-route-3d gpx-url="/examples/ibiza-trail.gpx" locale="en"></wodira-route-3d>Host your GPX on the same origin or enable CORS on the file server. Use the gpx property for XML text or tracks for prepared courses.
Courses stored in WODira
Section titled “Courses stored in WODira”<wodira-route-3d event-id="event_..." publishable-key="wpk_live_..." locale="en"></wodira-route-3d>A publishable key can only read its organization’s public courses from an allowed origin. Multiple courses appear as tabs. Use route-id to select the initial course.
Worker and customization
Section titled “Worker and customization”The map uses a MapLibre worker. With Vite, import the shipped file URL and set it before the GPX source:
import workerUrl from '@wodira/browser/ui/route-3d/worker?url';
const route = document.querySelector('wodira-route-3d');if (route) { route.workerUrl = new URL(workerUrl, location.href).href; route.gpxUrl = new URL('/examples/ibiza-trail.gpx', location.origin).href;}Without a bundler, serve dist/ui/route-3d/cdn.js and dist/ui/route-3d/maplibre-gl-worker.mjs together. Your CSP must allow the worker and connections to https://s3.amazonaws.com and https://server.arcgisonline.com.
Use --wodira-route-color for the course, figures and profile, and --wodira-route-height for height. Cooperative gestures preserve page scrolling; free-gestures disables them.
Events: wodira:route:ready provides routeId, distanceM and ascentM; wodira:route:selected provides routeId. Without WebGL, the elevation profile and GPX download remain available.