@@ -155,12 +155,29 @@ export class GeoArrowSolidPolygonLayer<
155
155
return null ;
156
156
}
157
157
158
- const pool = Pool < FunctionThread > (
159
- ( ) => spawn ( BlobWorker . fromText ( workerText ) ) ,
160
- 8 ,
161
- ) ;
162
- this . state . earcutWorkerPool = pool ;
163
- return this . state . earcutWorkerPool ;
158
+ // Some environments are not able to execute `importScripts`
159
+ // E.g. on a non-served HTML file (e.g. from lonboard export) you get
160
+ // Uncaught DOMException: Failed to execute 'importScripts' on
161
+ // 'WorkerGlobalScope': The script at
162
+ // 'blob:null/4ffb0b98-d1bd-4d9e-be52-998f50829723' failed to load.
163
+ //
164
+ // Additionally, it appears impossible to _catch_ this exception (at least
165
+ // on Chrome), so we'll hack around this by additionally checking if the
166
+ // current file is served from file://
167
+ if ( window ?. location ?. href . startsWith ( "file://" ) ) {
168
+ return null ;
169
+ }
170
+
171
+ try {
172
+ const pool = Pool < FunctionThread > (
173
+ ( ) => spawn ( BlobWorker . fromText ( workerText ) ) ,
174
+ 8 ,
175
+ ) ;
176
+ this . state . earcutWorkerPool = pool ;
177
+ return this . state . earcutWorkerPool ;
178
+ } catch ( err ) {
179
+ return null ;
180
+ }
164
181
}
165
182
166
183
async finalizeState ( context : LayerContext ) : Promise < void > {
@@ -513,7 +530,7 @@ export class GeoArrowSolidPolygonLayer<
513
530
recordBatchIdx,
514
531
tableOffsets : this . state . tableOffsets ,
515
532
516
- id : `${ this . props . id } -geoarrow-point -${ recordBatchIdx } ` ,
533
+ id : `${ this . props . id } -geoarrow-solid-polygon-multi -${ recordBatchIdx } ` ,
517
534
data : {
518
535
// @ts -expect-error passed through to enable use by function accessors
519
536
data : table . batches [ recordBatchIdx ] ,
@@ -553,7 +570,8 @@ export class GeoArrowSolidPolygonLayer<
553
570
} ) ;
554
571
}
555
572
556
- const layer = new SolidPolygonLayer ( this . getSubLayerProps ( props ) ) ;
573
+ const finalProps = this . getSubLayerProps ( props ) ;
574
+ const layer = new SolidPolygonLayer ( finalProps ) ;
557
575
layers . push ( layer ) ;
558
576
}
559
577
0 commit comments