From af03c5fe12b7f39b2d3efb815a977993e3da3149 Mon Sep 17 00:00:00 2001 From: Keith Paterson Date: Wed, 30 Dec 2020 18:15:47 +0100 Subject: [PATCH] Not interactive when not editing --- src/renderer/components/EditLayer.vue | 10 +++++++- .../loaders/TaxiwaySegmentExtender.js | 25 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/EditLayer.vue b/src/renderer/components/EditLayer.vue index 186f0ef..4f89ae7 100644 --- a/src/renderer/components/EditLayer.vue +++ b/src/renderer/components/EditLayer.vue @@ -206,7 +206,6 @@ You should have received a copy of the GNU General Public License along with FG this.featureLookup = []; this.groundnetLayerGroup.eachLayer(l => { l.enableEdit() - l.featureLookup = this.featureLookup; if (typeof l.extensions === 'function') { l.extensions(this) @@ -214,6 +213,12 @@ You should have received a copy of the GNU General Public License along with FG if (typeof l.bringToFront === 'function') { l.bringToFront() } + if (typeof l.updateStyle === 'function') { + l.updateStyle() + } + if (typeof l.setInteractive === 'function') { + l.setInteractive(true) + } }) this.$store.dispatch('addWip', {icao: this.icao}); }, disableEdit () { @@ -221,6 +226,9 @@ You should have received a copy of the GNU General Public License along with FG this.editing = false this.$store.commit('SET_EDIT', false) this.groundnetLayerGroup.eachLayer(l => { + if (typeof l.setInteractive === 'function') { + l.setInteractive(false) + } l.disableEdit() }) }, diff --git a/src/renderer/loaders/TaxiwaySegmentExtender.js b/src/renderer/loaders/TaxiwaySegmentExtender.js index 073cac5..998a27c 100644 --- a/src/renderer/loaders/TaxiwaySegmentExtender.js +++ b/src/renderer/loaders/TaxiwaySegmentExtender.js @@ -512,6 +512,26 @@ const extendTaxiSegment = function (taxiwaySegment) { } } + taxiwaySegment.__proto__.setInteractive = function (interactive) { + if (this.getLayers) { + this.getLayers().forEach(layer => { + layer.setInteractive(interactive); + }); + return; + } + if (!this._path) { + return; + } + + this.options.interactive = interactive; + + if (interactive) { + L.DomUtil.addClass(this._path, 'leaflet-interactive'); + } else { + L.DomUtil.removeClass(this._path, 'leaflet-interactive'); + } + }; + taxiwaySegment.__proto__.updateStyle = function () { var style = {}; if(!this.options.attributes) { @@ -525,6 +545,11 @@ const extendTaxiSegment = function (taxiwaySegment) { else { style.color = '#3388ff'; } + if(this.editEnabled()) { + style.interactive = true; + } else { + style.interactive = false; + } this.setStyle(style); if (this._map !== null) { if (this.options.attributes.direction === 'forward') {