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/temperature.js | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 assets/static/vendor/leaflet-elevation/src/handlers/temperature.js (limited to 'assets/static/vendor/leaflet-elevation/src/handlers/temperature.js') diff --git a/assets/static/vendor/leaflet-elevation/src/handlers/temperature.js b/assets/static/vendor/leaflet-elevation/src/handlers/temperature.js new file mode 100644 index 0000000..cf05308 --- /dev/null +++ b/assets/static/vendor/leaflet-elevation/src/handlers/temperature.js @@ -0,0 +1,62 @@ +export function Temperature() { + + const _ = L.Control.Elevation.Utils; + + let temperature = {}; + let opts = this.options; + temperature.label = opts.label || L._(opts.imperial ? '°F' : '°C'); + + // Fahrenheit = (Celsius * 9/5) + 32 + opts.temperatureFactor1 = opts.temperatureFactor1 ?? (opts.imperial ? 1.8 : 1); + opts.temperatureFactor2 = opts.temperatureFactor2 ?? (opts.imperial ? 32 : 0); + + return { + name: 'temperature', // <-- Your custom option name (eg. "temperature: true") + unit: temperature.label, + meta: 'atemps', // <-- point.meta.atemps + coordinateProperties: ["atemps"], // List of GPX Extensions ("coordinateProperties") to be handled by "@tmcw/toGeoJSON" + deltaMax: this.options.temperatureDeltaMax, + clampRange: this.options.temperatureRange, + decimals: 2, + pointToAttr: (point, i) => (point.meta.atemps ?? point.meta.atemps ?? point.prev('temperature')) * opts.temperatureFactor1 + opts.temperatureFactor2, + stats: { max: _.iMax, min: _.iMin, avg: _.iAvg }, + scale: { + axis : "y", + position : "right", + scale : { min: -1, max: +1 }, + tickPadding: 16, + labelX : +18, + labelY : -8, + }, + path: { + label : temperature.label, + yAttr : 'temperature', + scaleX : 'distance', + scaleY : 'temperature', + color : 'transparent', + strokeColor : '#000', + strokeOpacity: "0.85", + // fillOpacity : "0.1", + }, + tooltip: { + name: 'temperature', + chart: (item) => L._("Temp: ") + Math.round(item.temperature).toLocaleString() + " " + temperature.label, + marker: (item) => Math.round(item.temperature).toLocaleString() + " " + temperature.label, + order: 1 + }, + summary: { + "mintemp": { + label: "Min Temp: ", + value: (track, unit) => Math.round(track.temperature_min || 0) + ' ' + unit, + }, + "maxtemp": { + label: "Max Temp: ", + value: (track, unit) => Math.round(track.temperature_max || 0) + ' ' + unit, + }, + "avgtemp": { + label: "Avg Temp: ", + value: (track, unit) => Math.round(track.temperature_avg || 0) + ' ' + unit, + }, + } + }; +} -- cgit v1.3.1