mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 23:50:08 +00:00
fix(maps): draw with Leaflet wherever WebGL2 is missing
MapLibre 6 and Mapbox GL 3 both throw out of their Map constructor without WebGL2. Every place that builds a GL map now asks one helper first, components/Map/glSupport.ts, and a browser without WebGL2 gets the Leaflet map with the user's tiles instead of a map that fails to start: - the trip map (MapViewAuto) and the journey maps (JourneyMapAuto) pick their renderer through useGlRenderer, which folds in the Mapbox token rule they each had; - the settings preview, desktop and phone, shows the Leaflet preview through useMapSettingsForm and says why under it; - the tour planner keeps the 2D map when 3D is asked for and says that 3D needs WebGL2; - the PDF route map and the Leaflet vector basemap already fell back and now report a GPU failure too. Behind the probe, buildGlMap wraps each constructor (MapViewGL, JourneyMapGL, the settings preview, the terrain map, the PDF map). A GPU that claims WebGL2 and still refuses the context is reported through utils/webgl, which turns the answer to no and tells every mounted map, so they switch to Leaflet without a reload; any other error is still thrown. Two new strings, map.webgl2.fallback and map.webgl2.terrain, in all 27 locales.
This commit is contained in:
@@ -22,7 +22,7 @@ export default function MSettingsMap() {
|
||||
const {
|
||||
managed, saving, provider, changeProvider, mapTileUrl, setMapTileUrl, mapboxToken, setMapboxToken,
|
||||
cartoKey, setCartoKey, cartoNeedsKey, mapboxStyle, setMapboxStyle, mapbox3d, setMapbox3d,
|
||||
mapboxQuality, setMapboxQuality, previewPlaces, save,
|
||||
mapboxQuality, setMapboxQuality, previewPlaces, glPreview, webgl2Missing, save,
|
||||
} = useMapSettingsForm({ mirrorStyleBeforeSave: true })
|
||||
const [presetOpen, setPresetOpen] = useState(false)
|
||||
const [styleOpen, setStyleOpen] = useState(false)
|
||||
@@ -170,7 +170,7 @@ export default function MSettingsMap() {
|
||||
)}
|
||||
|
||||
<div className="relative mt-3 h-[200px] w-full overflow-hidden rounded-xl">
|
||||
{provider !== 'leaflet' ? (
|
||||
{glPreview ? (
|
||||
/* See MapSettingsTab: the preview gets its own net. */
|
||||
<ErrorBoundary boundaryId="settings:map-preview" resetKeys={[provider]} fallback={<div className="h-full w-full bg-m-card" />}>
|
||||
<Suspense fallback={<div className="h-full w-full bg-m-card animate-pulse" />}>
|
||||
@@ -208,6 +208,7 @@ export default function MSettingsMap() {
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
{webgl2Missing && <MSetHint>{t('map.webgl2.fallback')}</MSetHint>}
|
||||
|
||||
<MSetButton className="mt-3" onClick={save} disabled={saving}>
|
||||
<Save size={14} />
|
||||
|
||||
Reference in New Issue
Block a user