mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-04-29 18:25:58 +00:00
Bring Spothole mapping to parity with my other tools by adding choice of basemap, opacity and overlays #50
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
<p>This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.</p>
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-about").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -69,8 +69,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/add-spot.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/add-spot.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-add-spot").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -56,8 +56,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/alerts.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/alerts.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-alerts").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -62,9 +62,9 @@
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775242169"></script>
|
||||
<script src="/js/bands.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775377643"></script>
|
||||
<script src="/js/bands.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-bands").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -45,12 +45,11 @@
|
||||
integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/tinycolor2@1.6.0/cjs/tinycolor.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script>
|
||||
|
||||
<script src="https://misc.ianrenton.com/jsutils/utils.js?v=1775242169"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/storage.js?v=1775242169"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1775242169"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/geo.js?v=1775242169"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/utils.js?v=1775377643"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/storage.js?v=1775377643"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1775377643"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/geo.js?v=1775377643"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
26
templates/cards/basemap.html
Normal file
26
templates/cards/basemap.html
Normal file
@@ -0,0 +1,26 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Map Style</h5>
|
||||
<p class="card-text spothole-card-text">
|
||||
<label for="basemap" class="form-label">Basemap:</label>
|
||||
<select id="basemap" class="storeable-select form-select" oninput="displayUpdated();">
|
||||
<option value="OpenStreetMap.Mapnik" selected>OpenStreetMap Mapnik</option>
|
||||
<option value="Esri.NatGeoWorldMap">ESRI NatGeo World Map</option>
|
||||
<option value="Esri.WorldTopoMap">ESRI World Topo Map</option>
|
||||
<option value="Esri.WorldShadedRelief">ESRI World Shaded Relief</option>
|
||||
<option value="Esri.WorldImagery">ESRI World Imagery</option>
|
||||
<option value="CartoDB.Voyager">CartoDB Voyager</option>
|
||||
<option value="CartoDB.DarkMatter">CartoDB DarkMatter</option>
|
||||
</select>
|
||||
</p>
|
||||
<p class="card-text spothole-card-text">
|
||||
<label for="basemapOpacity" class="form-label">Opacity:</label>
|
||||
<select id="basemapOpacity" class="storeable-select form-select" oninput="displayUpdated();">
|
||||
<option value="1">100%</option>
|
||||
<option value="0.75">75%</option>
|
||||
<option value="0.5">50%</option>
|
||||
<option value="0.25">25%</option>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,11 +1,41 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Map Features</h5>
|
||||
<h5 class="card-title mb-3">Map Features</h5>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="mapShowGeodesics" value="mapShowGeodesics" oninput="displayUpdated();">
|
||||
<label class="form-check-label" for="mapShowGeodesics">Geodesic Lines</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="showTerminator" oninput="displayUpdated();" checked>
|
||||
<label class="form-check-label" for="showTerminator">Terminator / Greyline</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="showMaidenheadGrid" oninput="displayUpdated();">
|
||||
<label class="form-check-label" for="showMaidenheadGrid">Maidenhead Grid</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="showCQZones" oninput="displayUpdated();">
|
||||
<label class="form-check-label" for="showCQZones">CQ Zones</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="showITUZones" oninput="displayUpdated();">
|
||||
<label class="form-check-label" for="showITUZones">ITU Zones</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input storeable-checkbox" type="checkbox" id="showWABWAIGrid" oninput="displayUpdated();">
|
||||
<label class="form-check-label" for="showWABWAIGrid">WAB/WAI Grid</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -223,8 +223,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/conditions.js?v=1775242169"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/conditions.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-conditions").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
<div class="col">
|
||||
{% module Template("cards/spot-age.html", web_ui_options=web_ui_options) %}
|
||||
</div>
|
||||
<div class="col">
|
||||
{% module Template("cards/basemap.html", web_ui_options=web_ui_options) %}
|
||||
</div>
|
||||
<div class="col">
|
||||
{% module Template("cards/map-features.html", web_ui_options=web_ui_options) %}
|
||||
</div>
|
||||
@@ -65,14 +68,20 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet-providers@2.0.0/leaflet-providers.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet-extra-markers@1.2.2/src/assets/js/leaflet.extra-markers.min.js" type="module"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet.geodesic"></script>
|
||||
<script src="https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/text-image/dist/text-image.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@joergdietrich/leaflet.terminator@1.1.0/L.Terminator.min.js"></script>
|
||||
<script src="https://ianrenton.github.io/Leaflet.Maidenhead/src/L.Maidenhead.js"></script>
|
||||
<script src="https://ha8tks.github.io/Leaflet.ITUzones/src/L.ITUzones.js"></script>
|
||||
<script src="https://ha8tks.github.io/Leaflet.CQzones/src/L.CQzones.js"></script>
|
||||
<script src="https://misc.ianrenton.com/Leaflet.WorkedAllBritainIreland/L.WorkedAllBritainIreland.js"></script>
|
||||
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775242169"></script>
|
||||
<script src="/js/map.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775377643"></script>
|
||||
<script src="/js/map.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-map").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -87,9 +87,9 @@
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775242169"></script>
|
||||
<script src="/js/spots.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1775377643"></script>
|
||||
<script src="/js/spots.js?v=1775377643"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-spots").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -59,8 +59,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1775242169"></script>
|
||||
<script src="/js/status.js?v=1775242169"></script>
|
||||
<script src="/js/common.js?v=1775377643"></script>
|
||||
<script src="/js/status.js?v=1775377643"></script>
|
||||
<script>
|
||||
$(document).ready(function() { $("#nav-link-status").addClass("active"); }); <!-- highlight active page in nav -->
|
||||
</script>
|
||||
|
||||
@@ -220,11 +220,6 @@ div#map {
|
||||
font-family: var(--bs-body-font-family) !important;
|
||||
}
|
||||
|
||||
[data-bs-theme=dark] .leaflet-layer,
|
||||
[data-bs-theme=dark] .leaflet-control-attribution {
|
||||
filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
|
||||
}
|
||||
|
||||
/* Make buttons overlaid on the map have a non-transparent fill so you can see the text better */
|
||||
.btn-outline-secondary {
|
||||
--bs-btn-bg: var(--bs-body-bg) !important;
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
// How often to query the server?
|
||||
const REFRESH_INTERVAL_SEC = 60;
|
||||
|
||||
// Colours
|
||||
const MAIDENHEAD_GRID_COLOR_LIGHT = 'rgba(200, 140, 140, 1.0)';
|
||||
const CQ_ZONES_COLOR_LIGHT = 'rgba(140, 200, 140, 1.0)';
|
||||
const ITU_ZONES_COLOR_LIGHT = 'rgba(200, 200, 140, 1.0)';
|
||||
const WAB_WAI_GRID_COLOR_LIGHT = 'rgba(140, 140, 200, 1.0)';
|
||||
const MAIDENHEAD_GRID_COLOR_DARK = 'rgba(120, 60, 60, 1.0)';
|
||||
const CQ_ZONES_COLOR_DARK = 'rgba(60, 120, 60, 1.0)';
|
||||
const ITU_ZONES_COLOR_DARK = 'rgba(120, 120, 60, 1.0)';
|
||||
const WAB_WAI_GRID_COLOR_DARK = 'rgba(60, 60, 120, 1.0)';
|
||||
|
||||
// Map layers
|
||||
var backgroundTileLayer;
|
||||
var markersLayer;
|
||||
var geodesicsLayer;
|
||||
var terminator;
|
||||
var maidenheadGrid;
|
||||
var cqZones;
|
||||
var ituZones;
|
||||
var wabwaiGrid;
|
||||
// Tracks the currently-loaded basemap provider string to avoid unnecessary tile reloads
|
||||
var loadedBasemap;
|
||||
|
||||
// Load spots and populate the map.
|
||||
function loadSpots() {
|
||||
@@ -13,7 +30,9 @@ function loadSpots() {
|
||||
spots = jsonData;
|
||||
// Update map
|
||||
updateMap();
|
||||
if ($("#showTerminator")[0].checked) {
|
||||
terminator.setTime();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -184,6 +203,15 @@ function loadOptions() {
|
||||
// Load settings from settings storage now all the controls are available
|
||||
loadSettings();
|
||||
|
||||
// Apply basemap and overlay settings now that controls have their saved values
|
||||
setBasemap($("#basemap").val());
|
||||
setBasemapOpacity(parseFloat($("#basemapOpacity").val()));
|
||||
enableTerminator($("#showTerminator")[0].checked);
|
||||
enableMaidenheadGrid($("#showMaidenheadGrid")[0].checked);
|
||||
enableCQZones($("#showCQZones")[0].checked);
|
||||
enableITUZones($("#showITUZones")[0].checked);
|
||||
enableWABWAIGrid($("#showWABWAIGrid")[0].checked);
|
||||
|
||||
// Load spots and set up the timer
|
||||
loadSpots();
|
||||
setInterval(loadSpots, REFRESH_INTERVAL_SEC * 1000);
|
||||
@@ -193,9 +221,118 @@ function loadOptions() {
|
||||
// Method called when any display property is changed to reload the map and persist the display settings.
|
||||
function displayUpdated() {
|
||||
updateMap();
|
||||
setBasemap($("#basemap").val());
|
||||
setBasemapOpacity(parseFloat($("#basemapOpacity").val()));
|
||||
enableTerminator($("#showTerminator")[0].checked);
|
||||
enableMaidenheadGrid($("#showMaidenheadGrid")[0].checked);
|
||||
enableCQZones($("#showCQZones")[0].checked);
|
||||
enableITUZones($("#showITUZones")[0].checked);
|
||||
enableWABWAIGrid($("#showWABWAIGrid")[0].checked);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
// Set the basemap
|
||||
function setBasemap(basemapname) {
|
||||
// Only change if we have to, to avoid a flash of reloading content
|
||||
if (loadedBasemap !== basemapname) {
|
||||
loadedBasemap = basemapname;
|
||||
if (typeof backgroundTileLayer !== 'undefined') {
|
||||
map.removeLayer(backgroundTileLayer);
|
||||
}
|
||||
backgroundTileLayer = L.tileLayer.provider(basemapname, {
|
||||
opacity: parseFloat($("#basemapOpacity").val()),
|
||||
edgeBufferTiles: 1
|
||||
});
|
||||
backgroundTileLayer.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
|
||||
// Identify dark basemaps to ensure we use white text for unselected icons
|
||||
// and change the background colour appropriately
|
||||
const basemapIsDark = basemapname === "CartoDB.DarkMatter" || basemapname === "Esri.WorldImagery";
|
||||
$("#map").css('background-color', basemapIsDark ? "black" : "white");
|
||||
|
||||
// Change the colour of the grid and zone overlays to match
|
||||
if (basemapIsDark) {
|
||||
maidenheadGrid.options.color = MAIDENHEAD_GRID_COLOR_DARK;
|
||||
cqZones.options.color = CQ_ZONES_COLOR_DARK;
|
||||
ituZones.options.color = ITU_ZONES_COLOR_DARK;
|
||||
wabwaiGrid.options.color = WAB_WAI_GRID_COLOR_DARK;
|
||||
} else {
|
||||
maidenheadGrid.options.color = MAIDENHEAD_GRID_COLOR_LIGHT;
|
||||
cqZones.options.color = CQ_ZONES_COLOR_LIGHT;
|
||||
ituZones.options.color = ITU_ZONES_COLOR_LIGHT;
|
||||
wabwaiGrid.options.color = WAB_WAI_GRID_COLOR_LIGHT;
|
||||
}
|
||||
|
||||
// Force regenerate overlays in the new colours
|
||||
map.removeLayer(maidenheadGrid);
|
||||
map.removeLayer(cqZones);
|
||||
map.removeLayer(ituZones);
|
||||
map.removeLayer(wabwaiGrid);
|
||||
enableMaidenheadGrid($("#showMaidenheadGrid")[0].checked);
|
||||
enableCQZones($("#showCQZones")[0].checked);
|
||||
enableITUZones($("#showITUZones")[0].checked);
|
||||
enableWABWAIGrid($("#showWABWAIGrid")[0].checked);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the basemap opacity
|
||||
function setBasemapOpacity(opacity) {
|
||||
if (typeof backgroundTileLayer !== 'undefined') {
|
||||
backgroundTileLayer.setOpacity(opacity);
|
||||
}
|
||||
}
|
||||
|
||||
// Shows/hides the terminator/greyline overlay
|
||||
function enableTerminator(show) {
|
||||
if (show) {
|
||||
terminator.setTime();
|
||||
terminator.addTo(map);
|
||||
} else {
|
||||
map.removeLayer(terminator);
|
||||
}
|
||||
}
|
||||
|
||||
// Shows/hides the Maidenhead grid overlay
|
||||
function enableMaidenheadGrid(show) {
|
||||
if (show) {
|
||||
maidenheadGrid.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
} else {
|
||||
map.removeLayer(maidenheadGrid);
|
||||
}
|
||||
}
|
||||
|
||||
// Shows/hides the CQ zone overlay
|
||||
function enableCQZones(show) {
|
||||
if (show) {
|
||||
cqZones.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
} else {
|
||||
map.removeLayer(cqZones);
|
||||
}
|
||||
}
|
||||
|
||||
// Shows/hides the ITU zone overlay
|
||||
function enableITUZones(show) {
|
||||
if (show) {
|
||||
ituZones.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
} else {
|
||||
map.removeLayer(ituZones);
|
||||
}
|
||||
}
|
||||
|
||||
// Shows/hides the WAB/WAI grid overlay
|
||||
function enableWABWAIGrid(show) {
|
||||
if (show) {
|
||||
wabwaiGrid.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
} else {
|
||||
map.removeLayer(wabwaiGrid);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the map
|
||||
function setUpMap() {
|
||||
// Create map
|
||||
@@ -206,8 +343,9 @@ function setUpMap() {
|
||||
});
|
||||
|
||||
// Add basemap
|
||||
backgroundTileLayer = L.tileLayer.provider("OpenStreetMap.Mapnik", {
|
||||
opacity: 1,
|
||||
loadedBasemap = $("#basemap").val();
|
||||
backgroundTileLayer = L.tileLayer.provider(loadedBasemap, {
|
||||
opacity: parseFloat($("#basemapOpacity").val()),
|
||||
edgeBufferTiles: 1
|
||||
});
|
||||
backgroundTileLayer.addTo(map);
|
||||
@@ -221,12 +359,50 @@ function setUpMap() {
|
||||
geodesicsLayer = new L.LayerGroup();
|
||||
geodesicsLayer.addTo(map);
|
||||
|
||||
// Add terminator/greyline
|
||||
// Add terminator/greyline (toggleable)
|
||||
terminator = L.terminator({
|
||||
interactive: false
|
||||
});
|
||||
terminator.setStyle({fillColor: '#00000050'});
|
||||
if ($("#showTerminator")[0].checked) {
|
||||
terminator.addTo(map);
|
||||
}
|
||||
|
||||
// Add Maidenhead grid (toggleable)
|
||||
maidenheadGrid = L.maidenhead({
|
||||
color : MAIDENHEAD_GRID_COLOR_LIGHT
|
||||
});
|
||||
if ($("#showMaidenheadGrid")[0].checked) {
|
||||
maidenheadGrid.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
}
|
||||
|
||||
// Add CQ zone layer (toggleable)
|
||||
cqZones = L.cqzones({
|
||||
color : CQ_ZONES_COLOR_LIGHT
|
||||
});
|
||||
if ($("#showCQZones")[0].checked) {
|
||||
cqZones.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
}
|
||||
|
||||
// Add ITU zone layer (toggleable)
|
||||
ituZones = L.ituzones({
|
||||
color : ITU_ZONES_COLOR_LIGHT
|
||||
});
|
||||
if ($("#showITUZones")[0].checked) {
|
||||
ituZones.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
}
|
||||
|
||||
// Add WAB/WAI grid layer (toggleable)
|
||||
wabwaiGrid = L.workedAllBritainIreland({
|
||||
color : WAB_WAI_GRID_COLOR_LIGHT
|
||||
});
|
||||
if ($("#showWABWAIGrid")[0].checked) {
|
||||
wabwaiGrid.addTo(map);
|
||||
backgroundTileLayer.bringToBack();
|
||||
}
|
||||
|
||||
// Display a default view.
|
||||
map.setView([30, 0], 3);
|
||||
|
||||
Reference in New Issue
Block a user