mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
fix: the map falls back to raster where the vector style cannot load, the tour layer pill fits narrow maps and stands on the side in 3D, the dashboard's widget column scrolls on its own, and the CI checks the watch sync and journey write-up broke
This commit is contained in:
@@ -107,6 +107,26 @@ function attachGlLayer(map: L.Map, layer: GlLeafletLayer, style: string): boolea
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls `fail` once when the layer's style errors before it ever loaded. Errors
|
||||
* after that (a tile here and there) are the map's ordinary weather and leave it be.
|
||||
*/
|
||||
function onStyleFailure(layer: GlLeafletLayer, fail: () => void): void {
|
||||
const gl = layer.getMaplibreMap?.()
|
||||
if (!gl) return
|
||||
let loaded = false
|
||||
gl.once('style.load', () => {
|
||||
loaded = true
|
||||
})
|
||||
const onError = (event: { error?: unknown }) => {
|
||||
if (loaded) return
|
||||
gl.off('error', onError)
|
||||
console.warn('[basemap] the vector style did not load, drawing raster tiles', event.error)
|
||||
fail()
|
||||
}
|
||||
gl.on('error', onError)
|
||||
}
|
||||
|
||||
/**
|
||||
* The raster stand-in, attached imperatively for the maps that build Leaflet
|
||||
* themselves. The react-leaflet callers get the same tiles through the <TileLayer>
|
||||
@@ -201,6 +221,14 @@ export function VectorBasemap({ style }: { style: string }) {
|
||||
return
|
||||
}
|
||||
layerRef.current = layer
|
||||
// A style that never loads (its server, or the iOS app's offline protocol
|
||||
// failing) would leave the map white under its markers: raster instead.
|
||||
onStyleFailure(layer, () => {
|
||||
if (cancelled || layerRef.current !== layer) return
|
||||
detachBasemapLayer(layer)
|
||||
layerRef.current = null
|
||||
setGlUsable(false)
|
||||
})
|
||||
})()
|
||||
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user