Merge pull request #2108 from umap-project/copy-as-geojson

feat: add a "Copy as GeoJSON" entry in the contextmenu
This commit is contained in:
Yohan Boniface 2024-09-05 18:46:40 +02:00 committed by GitHub
commit dd79e8f923
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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))
}