@@ -57,6 +57,31 @@ const styleByTheme = {
5757 dark : "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json" ,
5858} ;
5959
60+ const fallbackStyle = {
61+ version : 8 ,
62+ sources : {
63+ osm : {
64+ type : "raster" ,
65+ tiles : [
66+ "https://tile.openstreetmap.org/{z}/{x}/{y}.png" ,
67+ "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png" ,
68+ ] ,
69+ tileSize : 256 ,
70+ attribution :
71+ '<a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer">© OpenStreetMap contributors</a>' ,
72+ } ,
73+ } ,
74+ layers : [
75+ {
76+ id : "osm-base" ,
77+ type : "raster" ,
78+ source : "osm" ,
79+ minzoom : 0 ,
80+ maxzoom : 19 ,
81+ } ,
82+ ] ,
83+ } as const ;
84+
6085const supportsWebgl = ( ) : boolean => {
6186 try {
6287 const canvas = document . createElement ( "canvas" ) ;
@@ -745,6 +770,7 @@ export function MapView({ isMapExpanded, onToggleMapExpanded }: MapViewProps) {
745770 const [ showTerrainOverlay , setShowTerrainOverlay ] = useState ( true ) ;
746771 const [ showSimulationSummary , setShowSimulationSummary ] = useState ( true ) ;
747772 const [ endpointPickError , setEndpointPickError ] = useState < string | null > ( null ) ;
773+ const [ useFallbackMapStyle , setUseFallbackMapStyle ] = useState ( false ) ;
748774 const [ interactionViewState , setInteractionViewState ] = useState < {
749775 longitude : number ;
750776 latitude : number ;
@@ -1100,8 +1126,13 @@ export function MapView({ isMapExpanded, onToggleMapExpanded }: MapViewProps) {
11001126 </ div >
11011127 ) : null }
11021128 { ! hasSimulationTerrain ? < div className = "map-control-note" > No SRTM loaded: simulation uses site elevations only.</ div > : null }
1129+ { useFallbackMapStyle ? (
1130+ < div className = "map-control-note map-control-note-secondary" >
1131+ Base map fallback active (OSM raster style).
1132+ </ div >
1133+ ) : null }
11031134 { endpointPickTarget && endpointPickError ? (
1104- < div className = "map-control-note map-control-note-secondary " > { endpointPickError } </ div >
1135+ < div className = "map-control-note map-control-note-tertiary " > { endpointPickError } </ div >
11051136 ) : null }
11061137 < aside className = "map-sim-summary" aria-live = "polite" >
11071138 < div className = "map-sim-summary-header" >
@@ -1174,7 +1205,12 @@ export function MapView({ isMapExpanded, onToggleMapExpanded }: MapViewProps) {
11741205 latitude : activeViewState . latitude ,
11751206 zoom : activeViewState . zoom ,
11761207 } }
1177- mapStyle = { styleByTheme [ theme ] }
1208+ mapStyle = { useFallbackMapStyle ? ( fallbackStyle as unknown as string ) : styleByTheme [ theme ] }
1209+ onError = { ( ) => {
1210+ if ( ! useFallbackMapStyle ) {
1211+ setUseFallbackMapStyle ( true ) ;
1212+ }
1213+ } }
11781214 interactiveLayerIds = { [ "link-lines" ] }
11791215 onClick = { onMapClick }
11801216 onMove = { ( event ) =>
0 commit comments