From eb2d36cc17d43fe08278e2056fb1d5e6cfd98cdb Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Sat, 7 Sep 2024 18:07:11 -0400 Subject: [PATCH] Now using dashed lines, fixed some JS. --- htdocs/lib/GoogleMaps.js | 26 +++++++++++++++++++------- htdocs/lib/Leaflet.js | 23 +++++++++++------------ htdocs/lib/MapCalls.js | 13 ++++++------- htdocs/lib/MapMarkers.js | 2 +- htdocs/map-google.js | 2 +- htdocs/map-leaflet.js | 2 +- owrx/map.py | 2 +- 7 files changed, 40 insertions(+), 30 deletions(-) diff --git a/htdocs/lib/GoogleMaps.js b/htdocs/lib/GoogleMaps.js index d074240f..50fc5d16 100644 --- a/htdocs/lib/GoogleMaps.js +++ b/htdocs/lib/GoogleMaps.js @@ -135,7 +135,7 @@ function GLocator() { GLocator.prototype = new Locator(); -GLocator.prototype.setMap = function(map) { +GLocator.prototype.setMap = function(map = null) { this.rect.setMap(map); }; @@ -166,17 +166,25 @@ GLocator.prototype.setOpacity = function(opacity) { // function GCall() { + const dash = { + path : 'M 0,-1 0,1', + scale : 2, + strokeWeight : 1, + strokeOpacity : 0.5 + }; + this.line = new google.maps.Polyline({ geodesic : true, - strokeColor : "#000000", - strokeOpacity : 0.2, - strokeWeight : 1 + strokeColor : '#000000', + strokeOpacity : 0, + strokeWeight : 0, + icons : [{ icon: dash, offset: 0, repeat: '8px' }] }); } GCall.prototype = new Call(); -GCall.prototype.setMap = function(map) { +GCall.prototype.setMap = function(map = null) { this.line.setMap(map); }; @@ -187,9 +195,13 @@ GCall.prototype.setEnds = function(lat1, lon1, lat2, lon2) { }; GCall.prototype.setColor = function(color) { - this.line.setOptions({ strokeColor: color }); + this.line.icons[0].icon.strokeColor = color; + this.line.setOptions({ icons: this.line.icons }); +// this.line.setOptions({ strokeColor: color }); }; GCall.prototype.setOpacity = function(opacity) { - this.line.setOptions({ strokeOpacity : opacity }); + this.line.icons[0].icon.strokeOpacity = opacity; + this.line.setOptions({ icons: this.line.icons }); +// this.line.setOptions({ strokeOpacity : opacity }); }; diff --git a/htdocs/lib/Leaflet.js b/htdocs/lib/Leaflet.js index 220a0297..2ae552e3 100644 --- a/htdocs/lib/Leaflet.js +++ b/htdocs/lib/Leaflet.js @@ -24,9 +24,8 @@ LMarker.prototype.setMarkerOptions = function(options) { } }; -LMarker.prototype.setMap = function (map) { - if (map) this._marker.addTo(map); - else this._marker.remove(); +LMarker.prototype.setMap = function (map = null) { + if (map) this._marker.addTo(map); else this._marker.remove(); }; LMarker.prototype.addListener = function (e, f) { @@ -85,9 +84,8 @@ function LLocator() { LLocator.prototype = new Locator(); -LLocator.prototype.setMap = function(map) { - if (map) this._rect.addTo(map); - else this._rect.remove(); +LLocator.prototype.setMap = function(map = null) { + if (map) this._rect.addTo(map); else this._rect.remove(); }; LLocator.prototype.setCenter = function(lat, lon) { @@ -116,17 +114,18 @@ LLocator.prototype.addListener = function (e, f) { function LCall() { this._line = L.polyline([[0, 0], [0, 0]], { - color : "#000000", - opacity : 0.2, - weight : 1 + dashArray : [4, 4], + dashOffset : 0, + color : '#000000', + opacity : 0.5, + weight : 1 }); } LCall.prototype = new Call(); -LCall.prototype.setMap = function(map) { - if (map) this._line.addTo(map); - else this._line.remove(); +LCall.prototype.setMap = function(map = null) { + if (map) this._line.addTo(map); else this._line.remove(); }; LCall.prototype.setEnds = function(lat1, lon1, lat2, lon2) { diff --git a/htdocs/lib/MapCalls.js b/htdocs/lib/MapCalls.js index c3f433f5..90ac567d 100644 --- a/htdocs/lib/MapCalls.js +++ b/htdocs/lib/MapCalls.js @@ -2,8 +2,7 @@ // Map Calls Management // -CallManager.strokeOpacity = 0.8; -CallManager.fillOpacity = 0.35; +CallManager.strokeOpacity = 0.5; function CallManager() { // Current calls @@ -89,11 +88,11 @@ Call.prototype.create = function(data, map) { Call.prototype.reColor = function(colorMode, filterBy = null) { this.setOpacity( - colorMode==='off'? 0.0 - : filterBy==null? 0.2 - : colorMode==='band' && this.band==filterBy? 0.2 - : colorMode==='mode' && this.mode==filterBy? 0.2 - : 0.0 + colorMode==='off'? 0 + : filterBy==null? CallManager.strokeOpacity + : colorMode==='band' && this.band==filterBy? CallManager.strokeOpacity + : colorMode==='mode' && this.mode==filterBy? CallManager.strokeOpacity + : 0 ); }; diff --git a/htdocs/lib/MapMarkers.js b/htdocs/lib/MapMarkers.js index 5dd07a19..f3908e6c 100644 --- a/htdocs/lib/MapMarkers.js +++ b/htdocs/lib/MapMarkers.js @@ -78,7 +78,7 @@ MarkerManager.prototype.toggle = function(map, type, onoff) { // Show or hide features on the map $.each(this.markers, function(_, x) { - if (x.mode === type) x.setMap(onoff ? map : undefined); + if (x.mode === type) x.setMap(onoff ? map : null); }); }; diff --git a/htdocs/map-google.js b/htdocs/map-google.js index 172ced1c..38c6cac0 100644 --- a/htdocs/map-google.js +++ b/htdocs/map-google.js @@ -195,7 +195,7 @@ MapManager.prototype.processUpdates = function(updates) { marker.update(update); // Assign marker to map - marker.setMap(self.mman.isEnabled(update.mode)? map : undefined); + marker.setMap(self.mman.isEnabled(update.mode)? map : null); // Apply marker options if (marker instanceof GFeatureMarker) { diff --git a/htdocs/map-leaflet.js b/htdocs/map-leaflet.js index b645676a..f159ebd4 100644 --- a/htdocs/map-leaflet.js +++ b/htdocs/map-leaflet.js @@ -485,7 +485,7 @@ MapManager.prototype.processUpdates = function(updates) { marker.update(update); // Assign marker to map - marker.setMap(self.mman.isEnabled(update.mode)? map : undefined); + marker.setMap(self.mman.isEnabled(update.mode)? map : null); // Apply marker options if (marker instanceof LFeatureMarker) { diff --git a/owrx/map.py b/owrx/map.py index dee92f29..d4a90705 100644 --- a/owrx/map.py +++ b/owrx/map.py @@ -125,7 +125,7 @@ class Map(object): "src": src, "dst": dst } - logger.debug("{0} call from {1} ({2}) to {3} ({4})".format(mode, key, src, callee, dst)) + logger.debug("{0} call from {1} to {2}".format(mode, key, callee)) # remove excessive calls while len(self.calls) > 0 and len(self.calls) >= max_calls: self.calls.pop(0)