From df0faa75aa38baa3c5be4214310dc86ae595c0cf Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 26 Feb 2025 15:38:48 +0100 Subject: [PATCH] feat: add a quick link to layer's permalink This will open a new page with only this given layer shown. --- umap/static/umap/js/modules/data/features.js | 6 ++++++ umap/static/umap/js/modules/data/layer.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 84529407..cc45dc30 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -640,6 +640,12 @@ class Feature { window.open(permalink) }, }) + items.push({ + label: translate('Layer permalink'), + action: () => { + window.open(this.datalayer.getPermalink()) + }, + }) } items.push({ label: translate('Copy as GeoJSON'), diff --git a/umap/static/umap/js/modules/data/layer.js b/umap/static/umap/js/modules/data/layer.js index dee5dd5b..281c6e02 100644 --- a/umap/static/umap/js/modules/data/layer.js +++ b/umap/static/umap/js/modules/data/layer.js @@ -1174,6 +1174,12 @@ export class DataLayer extends ServerStored { return this.options.name || translate('Untitled layer') } + getPermalink() { + return `${Utils.getBaseUrl()}?${Utils.buildQueryString({ datalayers: this.id })}${ + window.location.hash + }` + } + tableEdit() { if (!this.isVisible()) return const editor = new TableEditor(this._umap, this, this._leafletMap)