2424 */
2525L . ZoneLayer = L . GeoJSON . extend ( {
2626 options : {
27+ geojsonUrls : [
28+ "/js/nerc_regions.geojson" ,
29+ "/js/us_states.geojson" ,
30+ "/js/impactzone.geojson" ,
31+ ] ,
2732 /**
2833 * Determines which colors are assigned to what zones based on the GeoJSON data. Adjusting the return values of the switch statement
2934 * can change the colors of the zones. The cases for the switch statement will most likely have to be changed if a different
@@ -43,6 +48,14 @@ L.ZoneLayer = L.GeoJSON.extend({
4348 case 'TRE' : return { color : "#0000ff" } ;
4449 case 'WECC' : return { color : "#8000ff" } ;
4550 case '-' : return { color : "#808080" } ;
51+ default :
52+ // Fallback style for non-NERC geojsons (e.g. US state boundaries, impactzone)
53+ return {
54+ color : "#666666" ,
55+ weight : 1 ,
56+ fill : false ,
57+ opacity : 0.7 ,
58+ } ;
4659 }
4760 }
4861 } ,
@@ -57,13 +70,28 @@ L.ZoneLayer = L.GeoJSON.extend({
5770 initialize ( options ) {
5871 L . GeoJSON . prototype . initialize . call ( this , null , options ) ;
5972 this . _render = false ;
60- this . _geojson = null ;
73+ this . _geojsons = [ ] ;
6174
6275 ( async function ( zonelayer ) {
63- let geojson = await fetch ( "/js/nerc_regions.geojson" ) ;
64- geojson = await geojson . json ( ) ;
76+ const urls = zonelayer . options . geojsonUrls || [ ] ;
77+ const requests = urls . map ( ( url ) => fetch ( url ) ) ;
78+ const responses = await Promise . allSettled ( requests ) ;
6579
66- zonelayer . _geojson = geojson ;
80+ const loaded = [ ] ;
81+ for ( let i = 0 ; i < responses . length ; i ++ ) {
82+ const result = responses [ i ] ;
83+ const url = urls [ i ] ;
84+
85+ if ( result . status !== "fulfilled" || ! result . value . ok ) {
86+ console . warn ( "ZoneLayer failed to load:" , url ) ;
87+ continue ;
88+ }
89+
90+ const geojson = await result . value . json ( ) ;
91+ loaded . push ( geojson ) ;
92+ }
93+
94+ zonelayer . _geojsons = loaded ;
6795 zonelayer . toggleRender ( ) ;
6896 } ) ( this ) ;
6997 } ,
@@ -109,7 +137,9 @@ L.ZoneLayer = L.GeoJSON.extend({
109137 console . log ( "Zone rendering: " , this . _render ) ;
110138
111139 if ( this . _render ) {
112- this . addData ( this . _geojson ) ;
140+ for ( let i = 0 ; i < this . _geojsons . length ; i ++ ) {
141+ this . addData ( this . _geojsons [ i ] ) ;
142+ }
113143 } else {
114144 this . clearLayers ( ) ;
115145 }
0 commit comments