diff --git a/README.md b/README.md index b50d907..3c446dc 100644 --- a/README.md +++ b/README.md @@ -34,20 +34,23 @@ These are supplied with the URL to the page you want to embed, for example for a The supported parameters are as follows. Generally these match the equivalent parameters in the real Spothole API, where a mapping exists. -| Name | Allowed Values | Default | Example | Description | -|----------------|-------------------------|---------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `embedded` | `true`, `false` | `false` | `?embedded=true` | Enables embedded mode. | -| `color-scheme` | `light`, `dark`, `auto` | `auto` | `?color-scheme=dark` | Forces light or dark mode in preference to the operating system default. | -| `time-zone` | `UTC`, `local` | `UTC` | `?time-zone=local` | Sets times to be in UTC or local time. | -| `limit` | 10, 25, 50, 100 | 50 | `?limit=50` | Sets the number of spots that will be displayed on the main spots page | -| `limit` | 25, 50, 100, 200, 500 | 100 | `?limit=100` | Sets the number of alerts that will be displayed on the alerts page | -| `max_age` | 300, 600, 1800, 3600 | 1800 | `?max_age=1800` | Sets the maximum age of spots displayed on the map and bands pages, in seconds. | -| `band` | Comma-separated list | (all) | `?band=20m,40m` | Sets the list of bands that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | -| `sig` | Comma-separated list | (all) | `?sig=POTA,SOTA,NO_SIG` | Sets the list of SIGs that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | -| `source` | Comma-separated list | (all) | `?source=Cluster` | Sets the list of sources that will be shown on any spot or alert pages. Available options match the labels of the buttons in the standard web interface. | -| `mode_type` | Comma-separated list | (all) | `?mode_type=PHONE,CW` | Sets the list of mode types that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | -| `dx_continent` | Comma-separated list | (all) | `?dx_continent=NA,SA` | Sets the list of DX Continents that will be shown on any spot or alert pages. Available options match the labels of the buttons in the standard web interface. | -| `de_continent` | Comma-separated list | (all) | `?de_continent=EU` | Sets the list of DE Continents that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | +| Name | Allowed Values | Default | Example | Description | +|-------------------|-------------------------|---------|--------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `embedded` | `true`, `false` | `false` | `?embedded=true` | Enables embedded mode. | +| `color-scheme` | `light`, `dark`, `auto` | `auto` | `?color-scheme=dark` | Forces light or dark mode in preference to the operating system default. | +| `time-zone` | `UTC`, `local` | `UTC` | `?time-zone=local` | Sets times to be in UTC or local time. | +| `limit` | 10, 25, 50, 100 | 50 | `?limit=50` | Sets the number of spots that will be displayed on the main spots page | +| `limit` | 25, 50, 100, 200, 500 | 100 | `?limit=100` | Sets the number of alerts that will be displayed on the alerts page | +| `max_age` | 300, 600, 1800, 3600 | 1800 | `?max_age=1800` | Sets the maximum age of spots displayed on the map and bands pages, in seconds. | +| `band` | Comma-separated list | (all) | `?band=20m,40m` | Sets the list of bands that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | +| `sig` | Comma-separated list | (all) | `?sig=POTA,SOTA,NO_SIG` | Sets the list of SIGs that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | +| `source` | Comma-separated list | (all) | `?source=Cluster` | Sets the list of sources that will be shown on any spot or alert pages. Available options match the labels of the buttons in the standard web interface. | +| `mode_type` | Comma-separated list | (all) | `?mode_type=PHONE,CW` | Sets the list of mode types that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | +| `dx_continent` | Comma-separated list | (all) | `?dx_continent=NA,SA` | Sets the list of DX Continents that will be shown on any spot or alert pages. Available options match the labels of the buttons in the standard web interface. | +| `de_continent` | Comma-separated list | (all) | `?de_continent=EU` | Sets the list of DE Continents that will be shown on the spots, bands and map pages. Available options match the labels of the buttons in the standard web interface. | +| `map-center-lat` | Numeric (decimal) | (auto) | `?map-center-lat=51.5` | Sets the initial latitude of the map centre on the map page. If omitted, the map auto-fits to the loaded spots. | +| `map-center-lon` | Numeric (decimal) | (auto) | `?map-center-lon=-0.1` | Sets the initial longitude of the map centre on the map page. If omitted, the map auto-fits to the loaded spots. | +| `map-zoom` | Numeric (integer) | (auto) | `?map-zoom=6` | Sets the initial zoom level of the map on the map page. If omitted, the map auto-fits to the loaded spots. | More will be added soon to allow customisation of filters and other display properties. diff --git a/templates/about.html b/templates/about.html index 97b07af..1edd3b5 100644 --- a/templates/about.html +++ b/templates/about.html @@ -67,7 +67,7 @@

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.

- + {% end %} \ No newline at end of file diff --git a/templates/add_spot.html b/templates/add_spot.html index 94f0317..0c993e6 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -69,8 +69,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/alerts.html b/templates/alerts.html index bf8e21a..c7188f9 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -56,8 +56,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/bands.html b/templates/bands.html index bf73689..17e5f0f 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -62,9 +62,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 5a2e9d4..6497f30 100644 --- a/templates/base.html +++ b/templates/base.html @@ -46,10 +46,10 @@ crossorigin="anonymous"> - - - - + + + + diff --git a/templates/conditions.html b/templates/conditions.html index 22e3664..1ddfc8e 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -230,8 +230,8 @@ - - + + diff --git a/templates/map.html b/templates/map.html index 49a88a1..7c90f2f 100644 --- a/templates/map.html +++ b/templates/map.html @@ -79,9 +79,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/spots.html b/templates/spots.html index 3bc0f91..c6c0280 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -87,9 +87,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/status.html b/templates/status.html index 6da0800..9993357 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,8 +59,8 @@ - - + + diff --git a/webassets/js/map.js b/webassets/js/map.js index 5813b48..5db5b18 100644 --- a/webassets/js/map.js +++ b/webassets/js/map.js @@ -210,6 +210,7 @@ function loadOptions() { // to be called after these are set up, but if the URL params ask for "embedded mode", this will suppress // loading settings, so this needs to be called before that. loadURLParams(); + loadMapURLParams(); // Load settings from settings storage now all the controls are available loadSettings(); @@ -344,6 +345,30 @@ function enableWABWAIGrid(show) { } } +// Load map-specific URL parameters for center position and zoom level. +// These set Leaflet state directly rather than form controls, so they live here rather than in loadURLParams(). +// If any parameter is applied, firstLoad is set to false so updateMap() does not override the position. +function loadMapURLParams() { + let params = new URLSearchParams(document.location.search); + let lat = parseFloat(params.get("map-center-lat")); + let lon = parseFloat(params.get("map-center-lon")); + let zoom = parseFloat(params.get("map-zoom")); + + let hasLatLon = !isNaN(lat) && !isNaN(lon); + let hasZoom = !isNaN(zoom); + + if (hasLatLon || hasZoom) { + if (hasLatLon && hasZoom) { + map.setView([lat, lon], zoom); + } else if (hasLatLon) { + map.setView([lat, lon], map.getZoom()); + } else { + map.setZoom(zoom); + } + firstLoad = false; + } +} + // Set up the map function setUpMap() { // Create map @@ -415,7 +440,8 @@ function setUpMap() { backgroundTileLayer.bringToBack(); } - // Display a default view. + // Display a default view. This will only last until the spots are first loaded, at which point the map will zoom + // to the extent of ths spots. map.setView([30, 0], 3); }