diff --git a/src/renderer/components/EditLayer.vue b/src/renderer/components/EditLayer.vue index daa6322..2c233b9 100644 --- a/src/renderer/components/EditLayer.vue +++ b/src/renderer/components/EditLayer.vue @@ -249,6 +249,13 @@ console.error("Lookup " + index + " failed "); this.buildLookup() } + if (Number(this.$store.state.Editable.index) >= 0 && + this.featureLookup[this.$store.state.Editable.index]!==undefined) { + this.featureLookup[this.$store.state.Editable.index].forEach(element => { + element.deselect(); + }); + } + this.featureLookup[index].forEach((element, i) => { if (element instanceof L.Polyline) { element._latlngs.forEach((e1, index1) => { diff --git a/src/renderer/loaders/ParkingSpot.js b/src/renderer/loaders/ParkingSpot.js index 43fcbb9..deb9e80 100644 --- a/src/renderer/loaders/ParkingSpot.js +++ b/src/renderer/loaders/ParkingSpot.js @@ -182,29 +182,19 @@ L.ParkingSpot = L.Circle.extend({ }); this.on('editable:vertex:clicked', function (event) { console.debug(this.featureLookup[event.vertex.glueindex]); + if (Number(store.default.state.Editable.index) >= 0 && + this.featureLookup[store.default.state.Editable.index]!==undefined) { + this.featureLookup[store.default.state.Editable.index].forEach(element => { + if(element.deselect !== undefined) { + element.deselect(); + } + }); + } + if(event.target.editor._resizeLatLng.__vertex._icon !== event.sourceTarget._element){ event.vertex._icon.style['background-color'] = 'red'; store.default.dispatch('setParking', event.target.options.attributes); - this.select(); - this.unwatch = store.default.watch( - function (state) { - return state.Editable.data.parking; - }, - () => { - if(state === undefined || - state.index !== Number(event.target.glueindex)) { - if (event.target instanceof L.ParkingSpot) { - this.deselect(); - this.unwatch(); - } - } - } - , - { - deep: true //add this if u need to watch object properties change etc. - } - ); - + this.select(); } }); @@ -217,27 +207,19 @@ L.ParkingSpot = L.Circle.extend({ }, selectParking() { + if (Number(store.default.state.Editable.index) >= 0 && + this.featureLookup[store.default.state.Editable.index]!==undefined) { + this.featureLookup[store.default.state.Editable.index].forEach(element => { + if(element.deselect !== undefined) { + element.deselect(); + } + }); + } store.default.dispatch('setParking', this.options.attributes); store.default.dispatch('setParkingCoords', this.getLatLng().lat.toFixed(5) + ' ' + this.getLatLng().lng.toFixed(5)); this.select(); - this.unwatch = store.default.watch( - function (state) { - return state.Editable.data.parking; - }, - (state) => { - if(state === undefined || - state.index !== Number(this.options.attributes.index)) { - this.deselect(); - this.unwatch(); - } - } - , - { - deep: true //add this if u need to watch object properties change etc. - } - ); }, turfToLatLng: function (turfPoint) { return {lat: turfPoint.geometry.coordinates[1], lng: turfPoint.geometry.coordinates[0]}; diff --git a/src/renderer/loaders/RunwayNode.js b/src/renderer/loaders/RunwayNode.js index 4a4d5bf..ff9c1fd 100644 --- a/src/renderer/loaders/RunwayNode.js +++ b/src/renderer/loaders/RunwayNode.js @@ -25,27 +25,6 @@ L.RunwayNode = L.Marker.extend({ if (store.default.state.Editable.index !== event.target.options.attributes.index) { store.default.dispatch('setRunway', event.target.options.attributes); } - this.unwatch = store.default.watch( - function (state) { - return state.Editable.data.runway; - }, - (state) => { - // Reset colour - if(event.target instanceof L.RunwayNode && - event.target.options.attributes && - event.target.options.attributes.selected) { - event.target.options.attributes.selected = false; - event.target.deselect(); - this.unwatch(); - } - } - , - { - deep: true //add this if u need to watch object properties change etc. - - } - ); - }); }, select() {