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/components/summary.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 assets/static/vendor/leaflet-elevation/src/components/summary.js (limited to 'assets/static/vendor/leaflet-elevation/src/components/summary.js') diff --git a/assets/static/vendor/leaflet-elevation/src/components/summary.js b/assets/static/vendor/leaflet-elevation/src/components/summary.js new file mode 100644 index 0000000..e8da57f --- /dev/null +++ b/assets/static/vendor/leaflet-elevation/src/components/summary.js @@ -0,0 +1,43 @@ +const _ = L.Control.Elevation.Utils; + +export var Summary = L.Class.extend({ + initialize(opts, control) { + this.options = opts; + this.control = control; + this.labels = {}; + + let summary = this._container = _.create("div", "elevation-summary " + (opts.summary ? opts.summary + "-summary" : '')); + _.style(summary, 'max-width', opts.width ? opts.width + 'px' : ''); + }, + + render() { + return container => container.append(() => this._container); + }, + + reset() { + this._container.innerHTML = ''; + }, + + append(className, label, value) { + this._container.innerHTML += `${label}${value}`; + return this; + }, + + update() { + Object + .keys(this.labels) + .sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues? + .forEach((i)=> { + let value = typeof this.labels[i].value !== "function" ? this.labels[i].value : this.labels[i].value(this.control.track_info, this.labels[i].unit || ''); + this.append(i /*+ " order-" + this.labels[i].order*/, L._(this.labels[i].label), value, this.labels[i].order); + }); + }, + + _registerSummary(data) { + for (let i in data) { + data[i].order = data[i].order ?? 1000; + this.labels[i] = data[i]; + } + } + +}); -- cgit v1.3.1