diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index 805ffc9c..c36444a5 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -680,8 +680,8 @@ class Path extends Feature { edit(event) { if (this.map.editEnabled) { - if (!this.ui.editEnabled()) this.ui.enableEdit() super.edit(event) + if (!this.ui.editEnabled()) this.ui.makeGeometryEditable() } } diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 7dd5d0f6..04ecbdd2 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -281,6 +281,21 @@ const PathMixin = { } }, + makeGeometryEditable: function () { + if (this._map.editedFeature !== this.feature) { + this.disableEdit() + return + } + this._map.once('moveend', this.makeGeometryEditable, this) + const pointsCount = this._parts.reduce((acc, part) => acc + part.length, 0) + if (pointsCount > 100 && this._map.getZoom() < this._map.getMaxZoom()) { + this._map.tooltip.open({ content: L._('Please zoom in to edit the geometry') }) + this.disableEdit() + } else { + this.enableEdit() + } + }, + addInteractions: function () { FeatureMixin.addInteractions.call(this) this.on('editable:disable', this.onCommit) @@ -376,7 +391,7 @@ const PathMixin = { getContextMenuEditItems: function (event) { const items = FeatureMixin.getContextMenuEditItems.call(this, event) if ( - this._map?.editedFeature !== this && + this._map?.editedFeature !== this.feature && this.feature.isSameClass(this._map.editedFeature) ) { items.push({