From b8abc036841badb438df217fadaea8667c636130 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 5 Sep 2024 17:57:23 +0200 Subject: [PATCH] feat: add a "Copy as GeoJSON" entry in the contextmenu --- umap/static/umap/js/modules/rendering/ui.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 7dd5d0f6f..474631bde 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -93,13 +93,21 @@ const FeatureMixin = { getContextMenuItems: function (event) { const permalink = this.feature.getPermalink() let items = [] - if (permalink) + if (permalink) { items.push({ text: translate('Permalink'), callback: () => { window.open(permalink) }, }) + } + items.push({ + text: translate('Copy as GeoJSON'), + callback: () => { + L.Util.copyToClipboard(JSON.stringify(this.feature.toGeoJSON())) + this._map.tooltip.open({content: L._('Copied!')}) + }, + }) if (this._map.editEnabled && !this.feature.isReadOnly()) { items = items.concat(this.getContextMenuEditItems(event)) }