Non interactive layers

This commit is contained in:
Keith Paterson 2021-01-11 22:00:22 +01:00
parent 25e603d15f
commit ac53005c0d
8 changed files with 88 additions and 3 deletions

View File

@ -115,6 +115,8 @@ You should have received a copy of the GNU General Public License along with FG
this.centerDialogVisible = false this.centerDialogVisible = false
this.$parent.$parent.$refs.map.mapObject.options.minZoom = 1; this.$parent.$parent.$refs.map.mapObject.options.minZoom = 1;
this.$parent.$parent.$refs.editLayer.disableEdit() this.$parent.$parent.$refs.editLayer.disableEdit()
this.$parent.$parent.$refs.towerLayer.disableEdit()
this.$parent.$parent.$refs.thresholdLayer.disableEdit()
this.$parent.$parent.$refs.editLayer.reload(true) this.$parent.$parent.$refs.editLayer.reload(true)
}, },
undoLast () { undoLast () {
@ -123,6 +125,8 @@ You should have received a copy of the GNU General Public License along with FG
this.centerDialogVisible = false this.centerDialogVisible = false
this.$parent.$parent.$refs.map.mapObject.options.minZoom = 1; this.$parent.$parent.$refs.map.mapObject.options.minZoom = 1;
this.$parent.$parent.$refs.editLayer.disableEdit() this.$parent.$parent.$refs.editLayer.disableEdit()
this.$parent.$parent.$refs.towerLayer.disableEdit()
this.$parent.$parent.$refs.thresholdLayer.disableEdit()
this.$parent.$parent.$refs.editLayer.reload(false) this.$parent.$parent.$refs.editLayer.reload(false)
}, },
save () { save () {
@ -141,6 +145,8 @@ You should have received a copy of the GNU General Public License along with FG
this.$parent.$parent.$refs.towerLayer.save() this.$parent.$parent.$refs.towerLayer.save()
this.$parent.$parent.$refs.thresholdLayer.save() this.$parent.$parent.$refs.thresholdLayer.save()
this.$parent.$parent.$refs.editLayer.disableEdit() this.$parent.$parent.$refs.editLayer.disableEdit()
this.$parent.$parent.$refs.towerLayer.disableEdit()
this.$parent.$parent.$refs.thresholdLayer.disableEdit()
this.scanGroundnets() this.scanGroundnets()
Vue.set(this, 'saveDialogVisible', false) Vue.set(this, 'saveDialogVisible', false)
}, },

View File

@ -149,6 +149,10 @@ You should have received a copy of the GNU General Public License along with FG
if (l.updateArrows !== undefined) { if (l.updateArrows !== undefined) {
l.updateArrows(this.$store.state.Settings.zoom) l.updateArrows(this.$store.state.Settings.zoom)
} }
if (typeof l.setInteractive === 'function') {
l.setInteractive(false)
}
}) })
console.log(this.groundnetLayerGroup.maxId) console.log(this.groundnetLayerGroup.maxId)
this.buildLookup() this.buildLookup()
@ -224,7 +228,8 @@ You should have received a copy of the GNU General Public License along with FG
l.setInteractive(true) l.setInteractive(true)
} }
}) })
this.$store.dispatch('addWip', {icao: this.icao}); }, this.$store.dispatch('addWip', {icao: this.icao});
},
disableEdit () { disableEdit () {
this.editable = false this.editable = false
this.editing = false this.editing = false

View File

@ -258,6 +258,7 @@ You should have received a copy of the GNU General Public License along with FG
} }
this.$refs.editLayer.enableEdit() this.$refs.editLayer.enableEdit()
this.$refs.towerLayer.enableEdit() this.$refs.towerLayer.enableEdit()
this.$refs.thresholdLayer.enableEdit()
this.$refs.editBar.setEditing(event) this.$refs.editBar.setEditing(event)
this.$refs.toolBar.setEditing(event) this.$refs.toolBar.setEditing(event)
this.$refs.sidebar.setEditing(event) this.$refs.sidebar.setEditing(event)

View File

@ -77,6 +77,24 @@
this.deferredMountedTo(this.$parent.mapObject) this.deferredMountedTo(this.$parent.mapObject)
} }
}, },
enableEdit () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => {
if (l instanceof L.Threshold) {
l.setInteractive(true)
}
})
}
},
disableEdit () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => {
if (l instanceof L.Threshold) {
l.setInteractive(false)
}
})
}
},
setVisible (visible) { setVisible (visible) {
if (this.layerGroup !== undefined) { if (this.layerGroup !== undefined) {
if (visible !== this.visible) { if (visible !== this.visible) {

View File

@ -72,6 +72,15 @@ You should have received a copy of the GNU General Public License along with FG
}) })
} }
}, },
disableEdit () {
if (this.layerGroup) {
this.layerGroup.eachLayer(l => {
if (l instanceof L.TowerMarker) {
l.enableEdit(this.$parent.mapObject)
}
})
}
},
save () { save () {
if (this.layerGroup) { if (this.layerGroup) {
this.layerGroup.eachLayer(l => { this.layerGroup.eachLayer(l => {

View File

@ -239,7 +239,24 @@ L.ParkingSpot = L.Circle.extend({
if(this.box) { if(this.box) {
this.box.setStyle(style); this.box.setStyle(style);
} }
}, },
setInteractive(interactive) {
if (interactive) {
if(this.direction) {
L.DomUtil.addClass(this.direction._path, 'leaflet-interactive');
}
if(this.box) {
L.DomUtil.addClass(this.box._path, 'leaflet-interactive');
}
} else {
if(this.direction) {
L.DomUtil.removeClass(this.direction._path, 'leaflet-interactive');
}
if(this.box) {
L.DomUtil.removeClass(this.box._path, 'leaflet-interactive');
}
}
},
addListeners: function () { addListeners: function () {
this.on('editable:drawing:move', function (event) { this.on('editable:drawing:move', function (event) {
console.debug("Move Parking Spot: ", event); console.debug("Move Parking Spot: ", event);
@ -265,6 +282,7 @@ L.ParkingSpot = L.Circle.extend({
if(event.target.box !== undefined) { if(event.target.box !== undefined) {
event.target.box.addTo(event.target._map); event.target.box.addTo(event.target._map);
} }
event.target.setInteractive(false);
}); });
this.on('remove', function (event) { this.on('remove', function (event) {
console.log(event); console.log(event);

View File

@ -26,6 +26,20 @@ L.RunwayNode = L.Marker.extend({
store.default.dispatch('setRunway', event.target.options.attributes); store.default.dispatch('setRunway', event.target.options.attributes);
} }
}); });
this.on('add', function (event) {
event.target.setInteractive(false);
});
},
setInteractive(interactive) {
if (interactive) {
if(this._icon) {
L.DomUtil.addClass(this._icon, 'leaflet-interactive');
}
} else {
if(this._icon) {
L.DomUtil.removeClass(this._icon, 'leaflet-interactive');
}
}
}, },
select() { select() {
try { try {

View File

@ -27,6 +27,7 @@ L.Threshold = L.Marker.extend({
stopw_m: 0, stopw_m: 0,
originLatLng: null, originLatLng: null,
rwy: '', rwy: '',
interactive: false,
stripSVG: function(fName) { stripSVG: function(fName) {
var rx = /<\s*svg[^>]*>([\s\S]*)<\s*\/svg[^>]*>/gm; var rx = /<\s*svg[^>]*>([\s\S]*)<\s*\/svg[^>]*>/gm;
var svg = fs.readFileSync(path.join(__static, '/', fName), 'utf8'); var svg = fs.readFileSync(path.join(__static, '/', fName), 'utf8');
@ -48,6 +49,7 @@ L.Threshold = L.Marker.extend({
className: 'threshold-marker-icon', className: 'threshold-marker-icon',
html: `<div style=\'transform: translateX(${offset}px) translateY(${offset}px) scale(${scale}) rotate(${this.heading}deg); border: 1px red\'>${this.svg}</div>`, html: `<div style=\'transform: translateX(${offset}px) translateY(${offset}px) scale(${scale}) rotate(${this.heading}deg); border: 1px red\'>${this.svg}</div>`,
})); }));
this.setInteractive(this.interactive);
this.update(this.getLatLng()); this.update(this.getLatLng());
this.setLatLng(this.getLatLng()); this.setLatLng(this.getLatLng());
@ -55,6 +57,18 @@ L.Threshold = L.Marker.extend({
} }
} }
}, },
setInteractive(interactive) {
if (interactive) {
if(this._icon) {
L.DomUtil.addClass(this._icon, 'leaflet-interactive');
}
} else {
if(this._icon) {
L.DomUtil.removeClass(this._icon, 'leaflet-interactive');
}
}
this.interactive = interactive;
},
metersPerPixel: function (latitude, zoomLevel) { metersPerPixel: function (latitude, zoomLevel) {
var earthCircumference = 40075017; var earthCircumference = 40075017;
var latitudeRadians = latitude * (Math.PI / 180); var latitudeRadians = latitude * (Math.PI / 180);
@ -115,7 +129,7 @@ L.Threshold.addInitHook(function(){
store.default.dispatch('setThreshold', {rwy: event.target.rwy, displacement: event.target.displacement}); store.default.dispatch('setThreshold', {rwy: event.target.rwy, displacement: event.target.displacement});
}); });
this.on('add', function (event) { this.on('add', function (event) {
// event.target.direction.addTo(event.target._map); event.target.setInteractive(false);
}); });
}); });