Undefined layer if not found

This commit is contained in:
Keith Paterson 2020-12-21 16:35:31 +01:00
parent 8274fb882e
commit 0bb3021e3c
3 changed files with 31 additions and 22 deletions

View File

@ -196,7 +196,6 @@ You should have received a copy of the GNU General Public License along with FG
}, },
methods: { methods: {
ready (e) { ready (e) {
console.log(e)
e.on('layeradd', this.onLayerAdd) e.on('layeradd', this.onLayerAdd)
}, },
onLayerAdd (e) { onLayerAdd (e) {
@ -220,7 +219,7 @@ You should have received a copy of the GNU General Public License along with FG
this.layersControl.addOverlay(this.$refs.pavementLayer.getLayer(), 'APT Layer') this.layersControl.addOverlay(this.$refs.pavementLayer.getLayer(), 'APT Layer')
} }
} }
if (this.$refs.thresholdLayer.getLayer() === e.layer) { if (this.$refs.thresholdLayer !== undefined && this.$refs.thresholdLayer.getLayer() === e.layer) {
l = this.layersControl._layers.filter(l => l.name === 'Threshold Layer') l = this.layersControl._layers.filter(l => l.name === 'Threshold Layer')
if (l.length > 0 && l[0].layer !== this.$refs.thresholdLayer.getLayer()) { if (l.length > 0 && l[0].layer !== this.$refs.thresholdLayer.getLayer()) {
this.layersControl.removeLayer(l[0].layer) this.layersControl.removeLayer(l[0].layer)
@ -229,6 +228,7 @@ You should have received a copy of the GNU General Public License along with FG
if (l.length === 0) { if (l.length === 0) {
this.layersControl.addOverlay(this.$refs.thresholdLayer.getLayer(), 'Threshold Layer') this.layersControl.addOverlay(this.$refs.thresholdLayer.getLayer(), 'Threshold Layer')
} }
this.$refs.thresholdLayer.zoomUpdated()
} }
if (this.$refs.towerLayer !== undefined && this.$refs.towerLayer.getLayer() === e.layer) { if (this.$refs.towerLayer !== undefined && this.$refs.towerLayer.getLayer() === e.layer) {
l = this.layersControl._layers.filter(l => l.name === 'Tower Layer') l = this.layersControl._layers.filter(l => l.name === 'Tower Layer')
@ -239,6 +239,7 @@ You should have received a copy of the GNU General Public License along with FG
if (l.length === 0) { if (l.length === 0) {
this.layersControl.addOverlay(this.$refs.towerLayer.getLayer(), 'Tower Layer') this.layersControl.addOverlay(this.$refs.towerLayer.getLayer(), 'Tower Layer')
} }
this.$refs.towerLayer.zoomUpdated()
} }
}, },
onSelectedPolygon (ring) { onSelectedPolygon (ring) {
@ -348,11 +349,13 @@ You should have received a copy of the GNU General Public License along with FG
} }
this.$refs.pavementLayer.setVisible(zoom >= 12) this.$refs.pavementLayer.setVisible(zoom >= 12)
} }
if (this.$refs.editLayer.groundnetLayerGroup) {
this.$refs.editLayer.groundnetLayerGroup.eachLayer(function (layer) { this.$refs.editLayer.groundnetLayerGroup.eachLayer(function (layer) {
if (layer.updateArrows !== undefined) { if (layer.updateArrows !== undefined) {
layer.updateArrows(zoom) layer.updateArrows(zoom)
} }
}) })
}
if (this.$refs.thresholdLayer) { if (this.$refs.thresholdLayer) {
this.$refs.thresholdLayer.zoomUpdated() this.$refs.thresholdLayer.zoomUpdated()
} }

View File

@ -64,12 +64,14 @@
} }
}, },
zoomUpdated () { zoomUpdated () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => { this.layerGroup.eachLayer(l => {
if (l instanceof L.Threshold) { if (l instanceof L.Threshold) {
l.updateIcon(this.$parent.mapObject) l.updateIcon(this.$parent.mapObject)
} }
}) })
} }
}
}, },
computed: { computed: {

View File

@ -60,11 +60,13 @@ You should have received a copy of the GNU General Public License along with FG
} }
}, },
enableEdit () { enableEdit () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => { this.layerGroup.eachLayer(l => {
if (l instanceof L.TowerMarker) { if (l instanceof L.TowerMarker) {
l.enableEdit(this.$parent.mapObject) l.enableEdit(this.$parent.mapObject)
} }
}) })
}
}, },
save () { save () {
}, },
@ -82,12 +84,14 @@ You should have received a copy of the GNU General Public License along with FG
} }
}, },
zoomUpdated () { zoomUpdated () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => { this.layerGroup.eachLayer(l => {
if (l instanceof L.TowerMarker) { if (l instanceof L.TowerMarker) {
l.updateIcon(this.$parent.mapObject) l.updateIcon(this.$parent.mapObject)
} }
}) })
} }
}
}, },
computed: { computed: {
edit: function () { edit: function () {