From 622fd385142b9a91e26926638611da92787c18ba Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 17 Oct 2025 09:09:38 +0100 Subject: [PATCH] Geodesics #42 --- webassets/js/map.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/webassets/js/map.js b/webassets/js/map.js index 367df35..f8f8cae 100644 --- a/webassets/js/map.js +++ b/webassets/js/map.js @@ -1,5 +1,6 @@ // Map layers var markersLayer; +var geodesicsLayer; var terminator; // Load spots and populate the table. @@ -29,16 +30,29 @@ function buildQueryString() { function updateMap() { // Clear existing content markersLayer.clearLayers(); + geodesicsLayer.clearLayers(); // Make new markers for all spots with a good location, not QRT, and not a duplicate spot within the data set. var callsAlreadyDisplayed = []; spots.forEach(function (s) { if (s["dx_location_good"] && (s["qrt"] == null || s["qrt"] == false)) { if (!callsAlreadyDisplayed.includes(s["dx_call"])) { + // OK, create the marker - let m = L.marker([s["dx_latitude"], s["dx_longitude"]], {icon: getIcon(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); + } + } callsAlreadyDisplayed.push(s["dx_call"]); } @@ -198,6 +212,10 @@ function setUpMap() { markersLayer = new L.LayerGroup(); markersLayer.addTo(map); + // Add geodesic layer + geodesicsLayer = new L.LayerGroup(); + geodesicsLayer.addTo(map); + // Add terminator/greyline terminator = L.terminator({ interactive: false