diff --git a/htdocs/css/map.css b/htdocs/css/map.css index 8331d0d4..049f369f 100644 --- a/htdocs/css/map.css +++ b/htdocs/css/map.css @@ -72,7 +72,7 @@ ul { .openwebrx-map-legend select { background-color: #FFF; border-color: #DDD; - padding: 5px; + padding: 0 5px; } .openwebrx-map-console { @@ -95,3 +95,11 @@ ul { text-align: center; white-space: nowrap; } + +.leaflet-control-layers { + line-height: 0.5 !important; +} + +.leaflet-control-layers-expanded { + padding: 5px !important; +} diff --git a/htdocs/lib/MapMarkers.js b/htdocs/lib/MapMarkers.js index 6f2ceb6b..5c87f6cb 100644 --- a/htdocs/lib/MapMarkers.js +++ b/htdocs/lib/MapMarkers.js @@ -165,7 +165,8 @@ Marker.prototype.age = function(age) { // Remove visual marker element from its parent, if that element exists. Marker.prototype.remove = function() { if (this.div) { - this.div.parentNode.removeChild(this.div); + if (this.div.parentNode && this.div.parentNode.removeChild) + this.div.parentNode.removeChild(this.div); this.div = null; } }; diff --git a/htdocs/map-leaflet.js b/htdocs/map-leaflet.js index 9bd428a7..28a4b908 100644 --- a/htdocs/map-leaflet.js +++ b/htdocs/map-leaflet.js @@ -142,6 +142,13 @@ var mapExtraLayers = [ attribution: 'Map data: © OpenSeaMap contributors' }, }, + { + name: 'Maidenhead-QTH', + createLayer: async function () { + await $.when($.getScript('https://ha8tks.github.io/Leaflet.Maidenhead/src/L.Maidenhead.js')); + return L.maidenhead({ color: 'rgba(255, 0, 0, 0.4)' }); + } + }, ]; // reasonable default; will be overriden by server @@ -348,11 +355,17 @@ MapManager.prototype.initializeMap = function(receiver_gps, api_key, weather_key } function addMapOverlay (name) { - $.each(mapExtraLayers, function (idx, mel) { + $.each(mapExtraLayers, async function (idx, mel) { if (mel.name === name) { if (!mel.layer) { - mel.options.apikey = apiKeys[mel.depends]; - mel.layer = L.tileLayer(mel.url, mel.options); + if (apiKeys[mel.depends]) mel.options.apikey = apiKeys[mel.depends]; + if (typeof mel.url !== 'undefined') { + mel.layer = L.tileLayer(mel.url, mel.options); + } else if (typeof mel.createLayer === 'function') { + mel.layer = await mel.createLayer(); + } else { + console.error('Cannot create layer for ' + mel.name); + } } if (map.hasLayer(mel.layer)) map.removeLayer(mel.layer);