// Map layers var markersLayer; var geodesicsLayer; var terminator; // Load spots and populate the map. function loadSpots() { $.getJSON('/api/v1/spots' + buildQueryString(), function(jsonData) { // Store data spots = jsonData; // Update map updateMap(); terminator.setTime(); }); } // Build a query string for the API, based on the filters that the user has selected. function buildQueryString() { var str = "?"; ["dx_continent", "de_continent", "mode_type", "source", "band"].forEach(fn => { if (!allFilterOptionsSelected(fn)) { str = str + getQueryStringFor(fn) + "&"; } }); str = str + "max_age=" + $("#max-spot-age option:selected").val(); // Additional filters for the map view: No dupes, no QRT, only spots with good locations str = str + "&dedupe=true&allow_qrt=false&needs_good_location=true"; return str; } // Update the spots map function updateMap() { // Clear existing content markersLayer.clearLayers(); geodesicsLayer.clearLayers(); // Make new markers for all spots that match the filter spots.forEach(function (s) { var m = L.marker([s["dx_latitude"], s["dx_longitude"]], {icon: getIcon(s)}); m.bindPopup(getTooltipText(s)); markersLayer.addLayer(m); // Create geodesics if required if ($("#mapShowGeodesics")[0].checked && s["de_latitude"] != null && s["de_longitude"] != null) { var geodesic = L.geodesic([[s["de_latitude"], s["de_longitude"]], m.getLatLng()], { color: s["band_color"], wrap: false, steps: 5 }); geodesicsLayer.addLayer(geodesic); } }); } // Get an icon for a spot, based on its band, using PSK Reporter colours, its program etc. function getIcon(s) { return L.ExtraMarkers.icon({ icon: "fa-" + s["icon"], iconColor: s["band_contrast_color"], markerColor: s["band_color"], shape: 'circle', prefix: 'fa', svg: true }); } // Tooltip text for the markers function getTooltipText(s) { // Format DX call var dx_call = s["dx_call"]; if (dx_call == null) { dx_call = ""; dx_flag = ""; } if (s["dx_ssid"] != null) { dx_call = dx_call + "-" + s["dx_ssid"]; } // Format DX flag var dx_flag = ""; if (s["dx_flag"] && s["dx_flag"] != null && s["dx_flag"] != "") { dx_flag = s["dx_flag"]; } // Format the frequency var freq_string = "Unknown" if (s["freq"] != null) { var mhz = Math.floor(s["freq"] / 1000000.0); var khz = Math.floor((s["freq"] - (mhz * 1000000.0)) / 1000.0); var hz = Math.floor(s["freq"] - (mhz * 1000000.0) - (khz * 1000.0)); var hz_string = (hz > 0) ? hz.toFixed(0)[0] : ""; freq_string = `${mhz.toFixed(0)}${khz.toFixed(0).padStart(3, '0')}${hz_string}` } // Format comment var commentText = ""; if (s["comment"] != null) { commentText = escapeHtml(s["comment"]); } // Sig or fallback to source var sigSourceText = s["source"]; if (s["sig"]) { sigSourceText = s["sig"]; } // Format sig_refs var sig_refs = ""; if (s["sig_refs"] != null) { var items = [] for (var i = 0; i < s["sig_refs"].length; i++) { if (s["sig_refs"][i]["url"] != null) { items[i] = `${s["sig_refs"][i]["id"]}` } else { items[i] = `${s["sig_refs"][i]["id"]}` } } sig_refs = items.join(", "); } // DX ttt = `${dx_flag} ${dx_call}
`; // Frequency & band ttt += ` ${freq_string}`; if (s["band"] != null) { ttt += ` (${s["band"]})`; } // Mode if (s["mode"] != null) { ttt += `     ${s["mode"]}`; } ttt += "
"; // Source / SIG / Ref ttt += ` ${sigSourceText} ${sig_refs}
`; // Time ttt += ` ${moment.unix(s["time"]).fromNow()}`; // Comment if (commentText.length > 0) { ttt += `
${commentText}`; } return ttt; } // Load server options. Once a successful callback is made from this, we then query spots and set up the timer to query // spots repeatedly. function loadOptions() { $.getJSON('/api/v1/options', function(jsonData) { // Store options options = jsonData; // Add CSS for band toggle buttons addBandToggleColourCSS(options["bands"]); // Populate the filters panel generateBandsMultiToggleFilterCard(options["bands"]); generateMultiToggleFilterCard("#dx-continent-options", "dx_continent", options["continents"]); generateMultiToggleFilterCard("#de-continent-options", "de_continent", options["continents"]); generateMultiToggleFilterCard("#mode-options", "mode_type", options["mode_types"]); generateMultiToggleFilterCard("#source-options", "source", options["spot_sources"]); // Populate the Display panel options["web-ui-options"]["max-spot-age"].forEach(sc => $("#max-spot-age").append($('