diff options
| author | Dennis Fink | 2026-07-23 00:18:21 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-07-23 00:18:21 +0200 |
| commit | 1fe1d13c600b7dfe421b3b99b833b7d5d1232724 (patch) | |
| tree | 2e8636160cc1719c907be56f5ef8cbc7e0f10a53 /assets/static/vendor/leaflet-elevation/src/components/summary.js | |
| parent | ca77de06be474dfd712402c327dc436864d233a3 (diff) | |
| download | dennisfink.me-1fe1d13c600b7dfe421b3b99b833b7d5d1232724.tar.gz dennisfink.me-1fe1d13c600b7dfe421b3b99b833b7d5d1232724.zip | |
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.
Diffstat (limited to '')
| -rw-r--r-- | assets/static/vendor/leaflet-elevation/src/components/summary.js | 43 |
1 files changed, 43 insertions, 0 deletions
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 += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
+ 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];
+ }
+ }
+
+});
|
