Fix mapmoving

This commit is contained in:
portree_kid 2020-05-24 20:54:42 +02:00
parent 3ee9ec60e3
commit 294abffcc4
3 changed files with 25 additions and 20 deletions

View File

@ -68,7 +68,7 @@
}, },
airlines: function () { airlines: function () {
var airlineCodes = [] 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 var storedairlineCodes = this.$store.state.Airports.currentAirport.airlines
storedairlineCodes.forEach(element => { storedairlineCodes.forEach(element => {
airlineCodes.push({value: element, label: element}) airlineCodes.push({value: element, label: element})

View File

@ -508,13 +508,17 @@
}) })
}, },
editedParkings() { editedParkings() {
if(this.featureLookup===undefined) { if (this.featureLookup===undefined) {
console.warn("Lookup undefinded"); console.warn("Lookup undefinded");
this.buildLookup() this.buildLookup()
} }
if (this.featureLookup===undefined) {
return
}
console.log('Edited Parkings : ' + this.$store.state.Parkings.items) console.log('Edited Parkings : ' + this.$store.state.Parkings.items)
this.$store.state.Parkings.items.forEach( newElement => { this.$store.state.Parkings.items.forEach( newElement => {
console.debug(newElement); console.debug(newElement);
if(this.featureLookup[newElement.index]) {
this.featureLookup[newElement.index].forEach((element,index) => { this.featureLookup[newElement.index].forEach((element,index) => {
if (element instanceof L.ParkingSpot) { if (element instanceof L.ParkingSpot) {
element.options.attributes.name = newElement.name element.options.attributes.name = newElement.name
@ -523,6 +527,7 @@
//element.updateVertexFromDirection(); //element.updateVertexFromDirection();
} }
}) })
}
}) })
/* /*

View File

@ -60,7 +60,7 @@
mounted () { mounted () {
this.$store.dispatch('getAirports') this.$store.dispatch('getAirports')
this.$store.subscribe((mutation, state) => { 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.$parent)
// console.log(this.$store.state.Settings.bounds) // console.log(this.$store.state.Settings.bounds)
let airportsToLoad = this.$store.state.Airports.airports let airportsToLoad = this.$store.state.Airports.airports
@ -103,10 +103,11 @@
this.$store.dispatch('setCurrentAirport', icao) this.$store.dispatch('setCurrentAirport', icao)
}, },
visible (feature) { visible (feature) {
let bounds = this.$store.state.Settings.bounds let bounds
bounds = L.latLngBounds(L.latLng(bounds._southWest), L.latLng(bounds._northEast)) if (this.$refs.map) {
if (!bounds.hasOwnProperty('_northEast') && this.$refs.map) {
bounds = this.$refs.map.mapObject.getBounds() bounds = this.$refs.map.mapObject.getBounds()
} else {
return false
} }
let width = L.latLng(bounds._northEast).distanceTo(L.latLng(bounds._southWest)) let width = L.latLng(bounds._northEast).distanceTo(L.latLng(bounds._southWest))
// Load all airports in a minimum 5 km box // Load all airports in a minimum 5 km box
@ -158,6 +159,8 @@
event.target.bringToBack() event.target.bringToBack()
this.setIcao(item.properties.icao) this.setIcao(item.properties.icao)
this.$store.commit('SET_EDIT_AIRPORT', item.properties) 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) { zoomUpdated (zoom) {
if (zoom !== this.$store.state.Settings.zoom) { if (zoom !== this.$store.state.Settings.zoom) {
@ -167,20 +170,20 @@
} }
}, },
async centerUpdated (center) { async centerUpdated (center) {
/*
if (center !== this.$store.state.Settings.center) { if (center !== this.$store.state.Settings.center) {
this.$store.dispatch('setCenter', center) this.$store.dispatch('setCenter', center)
this.$refs.airportLayer.setVisible(this.zoom < 12) this.$refs.airportLayer.setVisible(this.zoom < 12)
this.$refs.pavementLayer.setVisible(this.zoom < 12) this.$refs.pavementLayer.setVisible(this.zoom < 12)
} }
*/
}, },
async boundsUpdated (bounds) { async boundsUpdated (bounds) {
/*
if (bounds !== this.$store.state.Settings.bounds) { if (bounds !== this.$store.state.Settings.bounds) {
this.$store.dispatch('setBounds', bounds) this.$store.dispatch('setBounds', bounds)
this.$refs.airportLayer.setVisible(this.zoom < 12) this.$refs.airportLayer.setVisible(this.zoom < 12)
this.$refs.pavementLayer.setVisible(this.zoom < 12) this.$refs.pavementLayer.setVisible(this.zoom < 12)
} }
*/
} }
}, },
computed: { computed: {
@ -188,10 +191,7 @@
return this.$store.state.Settings.zoom return this.$store.state.Settings.zoom
}, },
center: function () { center: function () {
let bounds = this.$store.state.Settings.bounds return this.$store.state.Settings.center
bounds = L.latLngBounds(L.latLng(bounds._southWest), L.latLng(bounds._northEast))
return bounds.getCenter()
} }
} }
} }