diff --git a/src/renderer/components/FlightgearMap.vue b/src/renderer/components/FlightgearMap.vue
index 79e97b7..ca6eade 100644
--- a/src/renderer/components/FlightgearMap.vue
+++ b/src/renderer/components/FlightgearMap.vue
@@ -162,7 +162,9 @@ You should have received a copy of the GNU General Public License along with FG
this.$refs.pavementLayer.load(airportsToLoad[0])
this.$refs.editLayer.load(airportsToLoad[0])
this.$refs.thresholdLayer.load(airportsToLoad[0])
- this.$refs.towerLayer.load(airportsToLoad[0])
+ if (this.$refs.towerLayer) {
+ this.$refs.towerLayer.load(airportsToLoad[0])
+ }
this.editingAirport = airportsToLoad[0]
})
}
@@ -228,7 +230,7 @@ You should have received a copy of the GNU General Public License along with FG
this.layersControl.addOverlay(this.$refs.thresholdLayer.getLayer(), 'Threshold Layer')
}
}
- if (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')
if (l.length > 0 && l[0].layer !== this.$refs.towerLayer.getLayer()) {
this.layersControl.removeLayer(l[0].layer)
@@ -338,7 +340,12 @@ You should have received a copy of the GNU General Public License along with FG
if (zoom !== this.$store.state.Settings.zoom) {
this.$store.dispatch('setZoom', zoom)
this.$refs.airportLayer.setVisible(zoom < 12)
- this.$refs.towerLayer.setVisible(this.zoom >= 12)
+ if (this.$refs.towerLayer) {
+ this.$refs.towerLayer.setVisible(this.zoom >= 12)
+ }
+ if (this.$refs.thresholdLayer) {
+ this.$refs.thresholdLayer.setVisible(this.zoom >= 12)
+ }
this.$refs.pavementLayer.setVisible(zoom >= 12)
}
this.$refs.editLayer.groundnetLayerGroup.eachLayer(function (layer) {
@@ -346,6 +353,9 @@ You should have received a copy of the GNU General Public License along with FG
layer.updateArrows(zoom)
}
})
+ if (this.$refs.thresholdLayer) {
+ this.$refs.thresholdLayer.zoomUpdated()
+ }
if (this.$refs.towerLayer) {
this.$refs.towerLayer.zoomUpdated()
}
@@ -354,7 +364,12 @@ You should have received a copy of the GNU General Public License along with FG
if (center !== this.$store.state.Settings.center) {
this.$store.dispatch('setCenter', center)
this.$refs.airportLayer.setVisible(this.zoom < 12)
- this.$refs.towerLayer.setVisible(this.zoom >= 12)
+ if (this.$refs.thresholdLayer) {
+ this.$refs.thresholdLayer.setVisible(this.zoom >= 12)
+ }
+ if (this.$refs.towerLayer) {
+ this.$refs.towerLayer.setVisible(this.zoom >= 12)
+ }
this.$refs.pavementLayer.setVisible(this.zoom >= 12)
}
},
diff --git a/src/renderer/components/ThresholdLayer.vue b/src/renderer/components/ThresholdLayer.vue
index 4ba902b..545186a 100644
--- a/src/renderer/components/ThresholdLayer.vue
+++ b/src/renderer/components/ThresholdLayer.vue
@@ -62,7 +62,15 @@
this.visible = visible
}
}
+ },
+ zoomUpdated () {
+ this.layerGroup.eachLayer(l => {
+ if (l instanceof L.Threshold) {
+ l.updateIcon(this.$parent.mapObject)
+ }
+ })
}
+
},
computed: {
edit: function () {
diff --git a/src/renderer/loaders/Threshold.js b/src/renderer/loaders/Threshold.js
index b50f506..27d3e57 100644
--- a/src/renderer/loaders/Threshold.js
+++ b/src/renderer/loaders/Threshold.js
@@ -10,143 +10,76 @@ FG Airports is distributed in the hope that it will be useful, but WITHOUT ANY W
You should have received a copy of the GNU General Public License along with FG Airports. If not, see http://www.gnu.org/licenses/.
*/
/* eslint-disable */
+
const convert = require('geo-coordinates-parser');
-const leaflet = require('leaflet');
-const turf = require('@turf/turf');
-const util = require('util');
-const store = require('../store');
+const fs = require('fs');
+const path = require('path');
-var $ = require('jquery');
-L.Threshold = L.Circle.extend({
- select() {
- var style = {};
- style['color'] = 'red';
- this.setStyle(style);
- },
- addListeners: function () {
- this.on('editable:drawing:move', function (event) {
- console.log("Move : ", event);
- console.log("Move : ", event.latlng);
- // Is it the edit vertex (Middle) moving?
- if(event.target.editor._resizeLatLng.__vertex._icon !== event.sourceTarget._element){
- event.target.setLatLng(event.latlng);
- event.target.updateVertexFromDirection();
- this.follow(event.target.id, event);
+/**http://wiki.openstreetmap.org/wiki/Zoom_levels*/
+
+
+L.Threshold = L.Marker.extend({
+ options: {
+ zIndexOffset: 20000,
+ },
+ stripSVG: function(fName) {
+ var rx = /<\s*svg[^>]*>([\s\S]*)<\s*\/svg[^>]*>/gm;
+ var svg = fs.readFileSync(path.join(__static, '/', fName), 'utf8');
+ var svg2 = rx.exec(svg);
+ return svg2[0];
+ },
+ updateIcon : function(map) {
+ console.debug(`Lat Lng Threshold ${this.getLatLng()}`);
+ if(map !== null) {
+ var metersPP = this.metersPerPixel(map.getCenter().lat, map.getZoom());
+ console.debug('Old Meters per pixel ' + this.metersPP);
+ console.debug('New Meters per pixel ' + metersPP);
+ if(this._metersPP != metersPP) {
+ var pixelSize = (this.iconSize/2) / metersPP;
+ var scale = pixelSize/this.iconSize;
+ var offset = 0;//-(this.iconSize/2);
+ this.setIcon(L.divIcon({
+ iconSize: 64,
+ className: 'threshold-marker-icon',
+ html: `