@@ -125,6 +125,14 @@ export default defineComponent({
125125 }
126126 return imgInternal ;
127127 }
128+ function failedToLoad(imgInternal : ImageDataItemInternal , loaded : boolean ) {
129+ if (loaded || local .imgs [imgInternal .frame ] !== imgInternal ) {
130+ return false ;
131+ }
132+ loadingImage .value = false ;
133+ emit (' load-error' , ` Could not load ${imgInternal .filename }. The file may have been moved or deleted. ` );
134+ return true ;
135+ }
128136 /**
129137 * Draw image to the GeoJS map, and update the map dimensions if they have changed.
130138 */
@@ -277,8 +285,8 @@ export default defineComponent({
277285 if (! imgInternal .cached ) {
278286 loadingImage .value = true ;
279287 // else wait for it to load
280- await imgInternal .onloadPromise ;
281- if (imgInternal .frame === data .frame ) {
288+ const loaded = await imgInternal .onloadPromise ;
289+ if (imgInternal .frame === data .frame && ! failedToLoad ( imgInternal , loaded ) ) {
282290 loadingImage .value = false ;
283291 // if the seek hasn't changed since the image completed loading, draw it.
284292 drawImage (imgInternal .image );
@@ -368,11 +376,21 @@ export default defineComponent({
368376
369377 if (local .imgs .length ) {
370378 const imgInternal = cacheFrame (0 );
371- imgInternal .onloadPromise .then (async () => {
379+ imgInternal .onloadPromise .then (async (loaded ) => {
380+ if (imgInternal .frame !== data .frame || failedToLoad (imgInternal , loaded )) {
381+ return ;
382+ }
372383 try {
373384 await imgInternal .image .decode ();
374385 } catch (error ) {
375- emit (' large-image-warning' , true );
386+ if (imgInternal .frame !== data .frame ) {
387+ return ;
388+ }
389+ loadingImage .value = false ;
390+ emit (' load-error' , ` Could not display ${imgInternal .filename }. Its resolution may be too large for this browser or hardware. ` , true );
391+ return ;
392+ }
393+ if (imgInternal .frame !== data .frame ) {
376394 return ;
377395 }
378396 initializeViewer (imgInternal .image .naturalWidth , imgInternal .image .naturalHeight );
@@ -428,8 +446,8 @@ export default defineComponent({
428446 drawImage (imgInternal .image );
429447 if (! imgInternal .cached ) {
430448 loadingImage .value = true ;
431- imgInternal .onloadPromise .then (() => {
432- if (imgInternal .frame === data .frame ) {
449+ imgInternal .onloadPromise .then ((loaded ) => {
450+ if (imgInternal .frame === data .frame && ! failedToLoad ( imgInternal , loaded ) ) {
433451 loadingImage .value = false ;
434452 drawImage (imgInternal .image );
435453 }
@@ -440,7 +458,10 @@ export default defineComponent({
440458 return ;
441459 }
442460 const imgInternal = cacheFrame (0 );
443- imgInternal .onloadPromise .then (() => {
461+ imgInternal .onloadPromise .then ((loaded ) => {
462+ if (failedToLoad (imgInternal , loaded )) {
463+ return ;
464+ }
444465 initializeViewer (imgInternal .image .naturalWidth , imgInternal .image .naturalHeight );
445466 const quadFeatureLayer = geoViewer .value .createLayer (' feature' , {
446467 features: [' quad' ],
0 commit comments