From 294abffcc4f9444a8dd9858df8e9b638a6d788ef Mon Sep 17 00:00:00 2001 From: portree_kid Date: Sun, 24 May 2020 20:54:42 +0200 Subject: [PATCH] Fix mapmoving --- src/renderer/components/AirportEdit.vue | 2 +- src/renderer/components/EditLayer.vue | 23 ++++++++++++++--------- src/renderer/components/FlightgearMap.vue | 20 ++++++++++---------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/renderer/components/AirportEdit.vue b/src/renderer/components/AirportEdit.vue index ba8a93d..336b991 100644 --- a/src/renderer/components/AirportEdit.vue +++ b/src/renderer/components/AirportEdit.vue @@ -68,7 +68,7 @@ }, airlines: function () { var airlineCodes = [] - if (this.$store.state.Airports.currentAirport !== undefined) { + if (this.$store.state.Airports.currentAirport !== undefined && this.$store.state.Airports.currentAirport.airlines) { var storedairlineCodes = this.$store.state.Airports.currentAirport.airlines storedairlineCodes.forEach(element => { airlineCodes.push({value: element, label: element}) diff --git a/src/renderer/components/EditLayer.vue b/src/renderer/components/EditLayer.vue index 4ca384b..c321627 100644 --- a/src/renderer/components/EditLayer.vue +++ b/src/renderer/components/EditLayer.vue @@ -508,21 +508,26 @@ }) }, editedParkings() { - if(this.featureLookup===undefined) { + if (this.featureLookup===undefined) { console.warn("Lookup undefinded"); this.buildLookup() } + if (this.featureLookup===undefined) { + return + } console.log('Edited Parkings : ' + this.$store.state.Parkings.items) this.$store.state.Parkings.items.forEach( newElement => { console.debug(newElement); - this.featureLookup[newElement.index].forEach((element,index) => { - if (element instanceof L.ParkingSpot) { - element.options.attributes.name = newElement.name - element.options.attributes.number = newElement.number - element.options.attributes.type = newElement.type - //element.updateVertexFromDirection(); - } - }) + if(this.featureLookup[newElement.index]) { + this.featureLookup[newElement.index].forEach((element,index) => { + if (element instanceof L.ParkingSpot) { + element.options.attributes.name = newElement.name + element.options.attributes.number = newElement.number + element.options.attributes.type = newElement.type + //element.updateVertexFromDirection(); + } + }) + } }) /* diff --git a/src/renderer/components/FlightgearMap.vue b/src/renderer/components/FlightgearMap.vue index a704940..a422d75 100644 --- a/src/renderer/components/FlightgearMap.vue +++ b/src/renderer/components/FlightgearMap.vue @@ -60,7 +60,7 @@ mounted () { this.$store.dispatch('getAirports') this.$store.subscribe((mutation, state) => { - if (mutation.type === 'BOUNDS' || mutation.type === 'SET_AIRPORTS') { + if (mutation.type === 'CENTER' || mutation.type === 'SET_AIRPORTS' || mutation.type === 'ZOOM') { // console.log(this.$parent) // console.log(this.$store.state.Settings.bounds) let airportsToLoad = this.$store.state.Airports.airports @@ -103,10 +103,11 @@ this.$store.dispatch('setCurrentAirport', icao) }, visible (feature) { - let bounds = this.$store.state.Settings.bounds - bounds = L.latLngBounds(L.latLng(bounds._southWest), L.latLng(bounds._northEast)) - if (!bounds.hasOwnProperty('_northEast') && this.$refs.map) { + let bounds + if (this.$refs.map) { bounds = this.$refs.map.mapObject.getBounds() + } else { + return false } let width = L.latLng(bounds._northEast).distanceTo(L.latLng(bounds._southWest)) // Load all airports in a minimum 5 km box @@ -158,6 +159,8 @@ event.target.bringToBack() this.setIcao(item.properties.icao) this.$store.commit('SET_EDIT_AIRPORT', item.properties) + let newCenter = L.latLng(item.geometry.coordinates[1], item.geometry.coordinates[0]) + this.$refs.map.setCenter(newCenter) }, zoomUpdated (zoom) { if (zoom !== this.$store.state.Settings.zoom) { @@ -167,20 +170,20 @@ } }, async centerUpdated (center) { - /* if (center !== this.$store.state.Settings.center) { this.$store.dispatch('setCenter', center) this.$refs.airportLayer.setVisible(this.zoom < 12) this.$refs.pavementLayer.setVisible(this.zoom < 12) } - */ }, async boundsUpdated (bounds) { + /* if (bounds !== this.$store.state.Settings.bounds) { this.$store.dispatch('setBounds', bounds) this.$refs.airportLayer.setVisible(this.zoom < 12) this.$refs.pavementLayer.setVisible(this.zoom < 12) } + */ } }, computed: { @@ -188,10 +191,7 @@ return this.$store.state.Settings.zoom }, center: function () { - let bounds = this.$store.state.Settings.bounds - bounds = L.latLngBounds(L.latLng(bounds._southWest), L.latLng(bounds._northEast)) - - return bounds.getCenter() + return this.$store.state.Settings.center } } }