diff --git a/htdocs/css/map.css b/htdocs/css/map.css index 8d78995e..a7c6539e 100644 --- a/htdocs/css/map.css +++ b/htdocs/css/map.css @@ -66,7 +66,7 @@ ul { border-width: 0; border-style: none; font-size: 24px; - text-alignment: center; + text-align: center; } .openwebrx-map-legend select { diff --git a/htdocs/lib/FeatureMarker.js b/htdocs/lib/FeatureMarker.js index 4003923b..3a7a64e7 100644 --- a/htdocs/lib/FeatureMarker.js +++ b/htdocs/lib/FeatureMarker.js @@ -1,3 +1,92 @@ +// +// Features Management +// + +function Features() { + // Currently known features + this.types = {}; + + // Colors used for features + this.colors = { + 'KiwiSDR' : '#800000', + 'WebSDR' : '#000080', + 'OpenWebRX' : '#006000' + }; + + // Symbols used for features + this.symbols = { + 'KiwiSDR' : '⨺', + 'WebSDR' : '◬', + 'OpenWebRX' : '⨹', + 'APRS' : '⚐', + 'AIS' : '⩯', + 'HFDL' : '✈' + }; + + // Feature type shown/hidden status + this.enabled = { + 'KiwiSDR' : false, + 'WebSDR' : false, + 'OpenWebRX' : false + }; +} + +Features.prototype.getColor = function(type) { + // Default color is black + return type in this.colors? this.colors[type] : '#000000'; +}; + +Features.prototype.getSymbol = function(type) { + // Default symbol is a rombus + return type in this.symbols? this.symbols[type] : '◇'; +}; + +Features.prototype.isEnabled = function(type) { + // Features are shown by default + return type in this.enabled? this.enabled[type] : true; +}; + +Features.prototype.toggle = function(map, markers, type, onoff) { + // Keep track of each feature table being show or hidden + this.enabled[type] = onoff; + + // Show or hide features on the map + $.each(markers, function(_, r) { + if (r.mode === type) r.setMap(onoff ? map : undefined); + }); +}; + +Features.prototype.addType = function(type) { + // Do not add feature twice + if (type in this.types) return; + + // Determine symbol and its color + var color = this.getColor(type); + var symbol = this.getSymbol(type); + var enabled = this.isEnabled(type); + + // Add type to the list of known types + this.types[type] = symbol; + this.enabled[type] = enabled; + + // If there is a list of features... + var $content = $(".openwebrx-map-legend").find('.features'); + if($content) + { + // Add visual list item for the type + $content.append( + '