Hide the Base map switch when there's no offline map to switch to
The Online/Offline sidebar icon was always shown, even on an install with no data/offline.pmtiles — offering a choice that can't actually work. LayerToggleControl#remove() removes the icon (and hides its panel) once the existing /api/offline-tiles check confirms there's nothing to switch to; a transient failure of that same-origin check leaves the switch as is rather than guessing, since that's the request itself failing, not evidence offline tiles are unavailable.
This commit is contained in:
1 parent
fd8852c0e1
commit
481233c232
2 files changed
+25
-6
No files matched your search
@@ -59,9 +59,11 @@ view (`public/js/map.js`) offers two styles:
|
||||
|
||||
`GET /api/offline-tiles` reports whether `data/offline.pmtiles` is
|
||||
present (`{"available": true|false}`); the frontend uses it once, on
|
||||
load, to default to the offline style when local tile data exists —
|
||||
otherwise it defaults to the online style. Either way, the layer
|
||||
toggle in the top-left of the map lets the user switch manually.
|
||||
load, to default to the offline style when local tile data exists.
|
||||
When it doesn't, `LayerToggleControl#remove()` (`public/js/map.js`)
|
||||
removes the Online/Offline sidebar icon entirely — a switch offering a
|
||||
choice that can't work is worse than no switch at all — so it's only
|
||||
ever shown on an install that actually has a PMTiles file to switch to.
|
||||
|
||||
PMTiles is a single, self-indexed file, which is why this needs no
|
||||
tile-decoding logic on the server: `app.rb`'s `/tiles/offline.pmtiles`
|
||||
|
||||
Reference in new issue
Block a user