Skip to content

Add a choice of base maps, each switchable in Settings → Map - #1340

Open
nagisml wants to merge 1 commit into
OpenSAK-Org:betafrom
nagisml:feature/747-map-layers
Open

nagisml wants to merge 1 commit into
OpenSAK-Org:betafrom
nagisml:feature/747-map-layers

Conversation

@nagisml

@nagisml nagisml commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

More choices for base maps (#747)

The map only offered OpenStreetMap. This PR adds a choice of base maps, including aerial and satellite imagery, as asked for in #747.

What changes for the user

  • Layer switcher on the map (top right) when more than one base map is switched on. The map last chosen is remembered.
  • Settings → Map → Base maps lists every map with an on/off checkbox, OpenStreetMap included. OpenStreetMap and OpenTopoMap are on by default. With nothing usable switched on, OpenStreetMap is still shown.
  • API keys: one field per provider (Esri ArcGIS, MapTiler, Thunderforest). Each field lists the maps its key unlocks and has a "Get a key" link to the provider's sign-up page.

Maps

Group Maps
Worldwide, no key OpenStreetMap, OpenTopoMap, CyclOSM, OSM Humanitarian
National open data, no key (tiles only inside the country) swisstopo (map, aerial), basemap.at (map, aerial), IGN France (map, aerial), PDOK (map, aerial), basemap.de, USGS (topo, aerial)
User's own API key Esri World Imagery, MapTiler Satellite and Outdoor, Thunderforest Outdoors and OpenCycleMap

Only sources whose terms allow use in an app like OpenSAK are included. Google and Bing are deliberately left out because their terms forbid direct tile access. A keyed map appears only once its key is entered, so the user holds the agreement with that provider.

Offline (#1111)

  • The new maps share the existing disk tile cache, each for as long as its provider's cache headers allow. MapTiler and Thunderforest explicitly allow caching on the device.
  • Esri allows caching only while connected. Its tiles are fetched through opensak://tiles/…, which Chromium never writes to its HTTP cache, so they never reach the disk. The Esri key also stays out of the page.
  • The offline time differs by provider: about a week for OSM, 7 days for OpenTopoMap, 14 for basemap.at, 21 for IGN, but only about 1 hour for swisstopo (short max-age).

Implementation

  • gui/map_layers.py (new): the list of maps (URL, attribution, zoom levels, bounds, key provider, offline flag).
  • gui/map_widget.py: builds one tile layer per available map, adds the Leaflet layer switcher, and reports the chosen map back to Python.
  • gui/web_assets.py: opensak://tiles/ tile proxy for maps whose provider doesn't allow tiles on the device.
  • gui/settings.py: map_base_layers, map_base_layer, map_api_keys, stored in opensak.json.
  • gui/dialogs/settings_dialog.py: the new Base maps section.
  • PRIVACY_POLICY.md §5.1 and the README credits name the new providers. I didn't change the policy's effective date; please say if it should change.

Translations

New and changed texts are in all 11 language files. The 10 non-English translations are machine-made, so corrections from native speakers are welcome.

Testing

  • New tests/unit-tests/test_map_layers_747.py. The full unit suite and mypy pass.
  • Checked in a real QtWebEngine page:
    • the switcher shows the switched-on maps;
    • swisstopo aerial tiles load;
    • an Esri tile comes through the proxy;
    • switching maps is saved;
    • swisstopo and OSM tiles land in the disk cache and Esri tiles don't.
  • Keyed maps: I only tested Esri with a real API key. MapTiler and Thunderforest are untested with real keys. I'd be happy if someone with a key for either could verify them. Their URLs follow the providers' documentation, and without a key the servers answer 403/401 as expected.

fixes #747

The map only offered OpenStreetMap. It now offers a list of base maps that
are legal to use in OpenSAK, in a layer switcher at the top right of the
map. The map last chosen is remembered.

Settings → Map → Base maps switches every map on or off, OpenStreetMap
included. OpenStreetMap and OpenTopoMap are on by default. With nothing
usable switched on, OpenStreetMap is still shown.

- Worldwide, no key: OpenStreetMap, OpenTopoMap, CyclOSM, OSM Humanitarian
- National open-data maps, limited to their country: swisstopo (map,
  aerial), basemap.at (map, aerial), IGN France (map, aerial), PDOK
  (map, aerial), basemap.de, USGS (topo, aerial)
- With the user's own API key, one per provider: Esri World Imagery,
  MapTiler Satellite and Outdoor, Thunderforest Outdoors and OpenCycleMap.
  A keyed map is offered only once its key is entered.

Google and Bing are left out because their terms forbid direct tile access.

Offline (OpenSAK-Org#1111): the new maps share the disk tile cache, each for as
long as its provider's cache headers allow. Esri allows caching only
while connected, so its tiles are fetched through opensak://tiles/,
which Chromium never writes to its HTTP cache. The Esri key also stays
out of the page.

The privacy policy (§5.1) and the README credits name the new
providers. Translations for the 10 non-English languages are
machine-made.

fixes OpenSAK-Org#747

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant