Layer visibility

This commit is contained in:
portree_kid 2020-07-08 11:33:31 +02:00
parent 4c01775ccf
commit bed38277ce
6 changed files with 37 additions and 23 deletions

View File

@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with FG
<Upload :visible.sync="uploadVisible" ref="upload"></Upload>
<ZoomButton icon="fas fa-th" v-on:click="zoomin" :show="true" tooltip="Zoomin"></ZoomButton>
<ZoomButton icon="fas fa-th-large" v-on:click="zoomout" :show="!editing" tooltip="Zoomout"></ZoomButton>
<ZoomButton icon="far fa-eye-slash" v-on:click="hideAPT" :show='true' tooltip="Hide APT"></ZoomButton>
<!--<ZoomButton icon="far fa-eye-slash" v-on:click="hideAPT" :show='true' tooltip="Hide APT"></ZoomButton>-->
<EditButton icon="fas fa-upload" v-on:click="upload" :show="!editing" tooltip="Upload"></EditButton>
<EditButton icon="fas fa-plane" v-on:click="test" :show="!editing" tooltip="Export"></EditButton>

View File

@ -14,6 +14,7 @@ You should have received a copy of the GNU General Public License along with FG
:zoom="zoom"
:center="center"
:options="options"
@ready="ready"
@update:zoom="zoomUpdated"
@update:center="centerUpdated"
@update:bounds="boundsUpdated"
@ -76,8 +77,6 @@ You should have received a copy of the GNU General Public License along with FG
components: { LMap, LTileLayer, LMarker, LCircle, LeafletSidebar, AiLayer, EditBar, ToolBar, EditLayer, PavementLayer, LLayerGroup, LControl, ThresholdLayer, ToolLayer },
props: [],
mounted () {
this.$refs.map.mapObject.on('layeradd', this.onLayerAdd)
this.$store.dispatch('getAirports')
this.$store.subscribe((mutation, state) => {
if (mutation.type === 'CENTER' || mutation.type === 'SET_AIRPORTS' || mutation.type === 'ZOOM') {
@ -87,11 +86,9 @@ You should have received a copy of the GNU General Public License along with FG
.filter(feature => this.visible(feature))
.map(feature => feature.properties.icao)
if (airportsToLoad.length > 0 && airportsToLoad[0] !== this.editingAirport && this.zoom > 12) {
this.$refs.editLayer.load(airportsToLoad[0])
this.$refs.pavementLayer.load(airportsToLoad[0])
/*
this.$refs.editLayer.load(airportsToLoad[0])
this.$refs.thresholdLayer.load(airportsToLoad[0])
*/
this.editingAirport = airportsToLoad[0]
}
if (this.$refs.editLayer) {
@ -119,11 +116,14 @@ You should have received a copy of the GNU General Public License along with FG
}
},
methods: {
ready (e) {
console.log(e)
e.on('layeradd', this.onLayerAdd)
},
onLayerAdd (e) {
if (this.layersControl === null) {
this.layersControl = L.control.layers({}, {}, {position: 'topleft'})
this.layersControl.addTo(this.$refs.map.mapObject)
debugger
var icon = this.layersControl._container.ownerDocument.createElement('I')
icon.className = 'fas fa-layer-group'
icon.style = 'padding-top: 9px; height: 30px; width: 30px; text-align: center; vertical-align: sub;'
@ -131,11 +131,18 @@ You should have received a copy of the GNU General Public License along with FG
// this.layersControl.addOverlay(this.$refs.thresholdLayer, 'Threshold Layer')
}
if (this.$refs.pavementLayer.getLayer() === e.layer) {
// debugger
var l = this.layersControl._layers.filter(l => l.name === 'APT Layer')
if (l.length === 0) {
this.layersControl.addOverlay(this.$refs.pavementLayer.getLayer(), 'APT Layer')
}
}
if (this.$refs.thresholdLayer.getLayer() === e.layer) {
l = this.layersControl._layers.filter(l => l.name === 'Threshold Layer')
if (l.length === 0) {
this.layersControl.addOverlay(this.$refs.thresholdLayer.getLayer(), 'Threshold Layer')
}
}
},
onSelectedPolygon (ring) {
var parkings = this.$refs.editLayer.getParkings(ring)

View File

@ -25,10 +25,14 @@
}
},
methods: {
getLayer () {
return this.layerGroup
},
load (icao) {
// Callback for add
this.layerGroup = readThresholdXML(this.$store.state.Settings.settings.airportsDirectory, icao, this.read)
this.layerGroup.addTo(this.$parent.mapObject)
this.visible = true
this.icao = icao
},
deferredMountedTo (parent) {
@ -45,10 +49,13 @@
},
setVisible (visible) {
if (this.layerGroup !== undefined) {
if (visible) {
this.layerGroup.addTo(this.$parent.mapObject)
} else {
this.layerGroup.removeFrom(this.$parent.mapObject)
if (visible !== this.visible) {
if (visible) {
this.layerGroup.addTo(this.$parent.mapObject)
} else {
this.layerGroup.removeFrom(this.$parent.mapObject)
}
this.visible = visible
}
}
}

View File

@ -34,7 +34,7 @@ exports.addFeature = function (feature) {
exports.readGroundnetXML = function (fDir, icao, force) {
try {
layerGroup = L.layerGroup();
var layerGroup = L.layerGroup();
layerGroup.maxId = 0;
var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.xml');
var fNew = path.join(fDir, icao[0], icao[1], icao[2], icao + '.groundnet.new.xml');

View File

@ -209,7 +209,7 @@ function deCasteljau(pointArray) {
return intermediates;
}
function createPoly(currentFeature) {
function createPoly(currentFeature, layerGroup) {
switch (module.exports.type) {
case 110:
var taxiwayPoly = new L.Polygon(currentFeature);
@ -231,7 +231,7 @@ function createPoly(currentFeature) {
}
}
function createLineString(currentFeature) {
function createLineString(currentFeature, layerGroup) {
switch (module.exports.type) {
case 110:
var taxiwayPoly = new L.Polyline(currentFeature);
@ -255,7 +255,7 @@ function createLineString(currentFeature) {
module.exports.readPavement = function (f, icao, cb) {
console.log(f);
layerGroup = L.layerGroup();
var pavementLayerGroup = L.layerGroup();
var currentFeature;
lineReader.createInterface({
@ -267,7 +267,7 @@ module.exports.readPavement = function (f, icao, cb) {
return;
var scanMethod = scanMethods[fields[0]];
if (scanMethod != null) {
currentFeature = scanMethod(fields, icao, layerGroup, currentFeature);
currentFeature = scanMethod(fields, icao, pavementLayerGroup, currentFeature);
}
else {
if (fields[0] == '99') {
@ -280,7 +280,7 @@ module.exports.readPavement = function (f, icao, cb) {
lr.close();
}).on('close', function () {
console.log("End");
cb(layerGroup);
cb(pavementLayerGroup);
});
}
@ -381,7 +381,7 @@ var scanMethods = {
if (!module.exports.isScanning)
return undefined;
if (typeof currentFeature !== 'undefined') {
createPoly(currentFeature);
createPoly(currentFeature, layerGroup);
}
module.exports.colour = 'grey';
module.exports.type = 110;
@ -391,7 +391,7 @@ var scanMethods = {
if (!module.exports.isScanning)
return undefined;
if (typeof currentFeature !== 'undefined') {
createPoly(currentFeature);
createPoly(currentFeature, layerGroup);
}
module.exports.colour = 'yellow';
module.exports.type = 120;
@ -401,7 +401,7 @@ var scanMethods = {
if (!module.exports.isScanning)
return undefined;
if (typeof currentFeature !== 'undefined') {
createPoly(currentFeature);
createPoly(currentFeatur, layerGroup);
}
module.exports.colour = 'black';
module.exports.type = 130;
@ -463,7 +463,7 @@ var scanMethods = {
else {
currentFeature.slice(-1)[0].push([line[1], line[2]]);
}
createLineString(currentFeature);
createLineString(currentFeature, layerGroup);
exports.bezierPoint = null;
},
// End with Bezier
@ -472,7 +472,7 @@ var scanMethods = {
return;
console.debug(line);
currentFeature = bezier(line, icao, layerGroup, currentFeature);
createLineString(currentFeature);
createLineString(currentFeature, layerGroup);
exports.bezierPoint = null;
// taxiwayLine.addTo(layerGroup);
},

View File

@ -15,7 +15,7 @@ var $ = require('jquery');
exports.readThresholdXML = function (fDir, icao, force) {
try {
layerGroup = L.layerGroup();
var layerGroup = L.layerGroup();
layerGroup.maxId = 0;
var f = path.join(fDir, icao[0], icao[1], icao[2], icao + '.threshold.xml');
var fNew = path.join(fDir, icao[0], icao[1], icao[2], icao + '.threshold.new.xml');