From 1fe1d13c600b7dfe421b3b99b833b7d5d1232724 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Thu, 23 Jul 2026 00:18:21 +0200 Subject: Add GPX trail maps to blog posts This adds a trail flow block so posts can include attached GPX files as interactive maps with route display, elevation charts, activity summaries, and start/finish markers. The trail assets are loaded only when needed, keeping the shared templates clean while vendoring the Leaflet dependencies required for offline, self-hosted map rendering. --- .../leaflet-elevation/src/handlers/altitude.js | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 assets/static/vendor/leaflet-elevation/src/handlers/altitude.js (limited to 'assets/static/vendor/leaflet-elevation/src/handlers/altitude.js') diff --git a/assets/static/vendor/leaflet-elevation/src/handlers/altitude.js b/assets/static/vendor/leaflet-elevation/src/handlers/altitude.js new file mode 100644 index 0000000..b7fe6e3 --- /dev/null +++ b/assets/static/vendor/leaflet-elevation/src/handlers/altitude.js @@ -0,0 +1,78 @@ +export function Altitude() { + + const _ = L.Control.Elevation.Utils; + + let opts = this.options; + let altitude = {}; + + let theme = opts.theme.split(' ')[0].replace('-theme', ''); + let color = _.Colors[theme] || {}; + + opts.altitudeFactor = opts.imperial ? this.__footFactor : (opts.altitudeFactor || 1); // 1 m = (1 m) + altitude.label = opts.imperial ? "ft" : opts.yLabel; + + return { + name: 'altitude', + required: this.options.slope, + meta: 'z', + unit: altitude.label, + statsName: 'elevation', + deltaMax: this.options.altitudeDeltaMax, + clampRange: this.options.altitudeRange, + // init: ({point}) => { + // // "alt" property is generated inside "leaflet" + // if ("alt" in point) point.meta.ele = point.alt; + // }, + pointToAttr: (point, i) => { + if ("alt" in point) point.meta.ele = point.alt; // "alt" property is generated inside "leaflet" + return this._data[i].z *= opts.altitudeFactor; + }, + stats: { max: _.iMax, min: _.iMin, avg: _.iAvg }, + grid: { + axis : "y", + position : "left", + scale : "y" // this._chart._y, + }, + scale: { + axis : "y", + position: "left", + scale : "y", // this._chart._y, + labelX : -3, + labelY : -8, + }, + path: { + label : 'Altitude', + scaleX : 'distance', + scaleY : 'altitude', + className : 'area', + color : color.area || theme, + strokeColor : opts.detached ? color.stroke : '#000', + strokeOpacity: "1", + fillOpacity : opts.detached ? (color.alpha || '0.8') : 1, + preferCanvas : opts.preferCanvas, + }, + tooltip: { + name: 'y', + chart: (item) => L._("y: ") + _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label, + marker: (item) => _.round(item[opts.yAttr], opts.decimalsY) + " " + altitude.label, + order: 10, + }, + summary: { + "minele" : { + label: "Min Elevation: ", + value: (track, unit) => (track.elevation_min || 0).toFixed(2) + ' ' + unit, + order: 30, + }, + "maxele" : { + label: "Max Elevation: ", + value: (track, unit) => (track.elevation_max || 0).toFixed(2) + ' ' + unit, + order: 31, + }, + "avgele" : { + label: "Avg Elevation: ", + value: (track, unit) => (track.elevation_avg || 0).toFixed(2) + ' ' + unit, + order: 32, + }, + } + }; +} -- cgit v1.3.1