diff --git a/src/layer/Layer.ts b/src/layer/Layer.ts index c20997c86e..e88ae3fde0 100644 --- a/src/layer/Layer.ts +++ b/src/layer/Layer.ts @@ -421,9 +421,7 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { const map = this.getMap(); if (renderer && map && map.getRenderer()) { - //fire show at renderend to make sure layer is shown - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Map 缺少once方法 + //fire show in next frame to make sure layer is shown map.getRenderer().callInNextFrame(() => { this.fire('show'); }); @@ -459,9 +457,7 @@ class Layer extends JSONAble(Eventable(Renderable(Class))) { const map = this.getMap(); if (renderer && map && map.getRenderer()) { - //fire hide at renderend to make sure layer is hidden - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore Map 缺少once方法 + //fire hide in next frame to make sure layer is hidden map.getRenderer().callInNextFrame(() => { this.fire('hide'); }); diff --git a/src/layer/tile/TileLayer.ts b/src/layer/tile/TileLayer.ts index 675fe5dc33..5f2c716ef3 100644 --- a/src/layer/tile/TileLayer.ts +++ b/src/layer/tile/TileLayer.ts @@ -26,6 +26,7 @@ import * as vec3 from '../../core/util/vec3'; import { formatResourceUrl } from '../../core/ResourceProxy'; import { Coordinate, Extent } from '../../geo'; import { type TileLayerCanvasRenderer } from '../../renderer'; +import { Tile } from '../../renderer/layer/tilelayer/TileLayerCanvasRenderer'; import { BBOX, bboxInMask } from '../../core/util/bbox'; const DEFAULT_MAXERROR = 1; @@ -114,7 +115,7 @@ const options: TileLayerOptionsType = { 'loadingLimitOnInteracting': 3, 'loadingLimit': 0, - 'tileRetryCount': 0, + // 'tileRetryCount': 0, 'placeholder': false, @@ -1690,7 +1691,8 @@ export type TileLayerOptionsType = LayerOptionsType & { maxCacheSize?: number; cascadeTiles?: boolean; zoomOffset?: number; - tileRetryCount?: number; + reloadErrorTileFunction?: (layer: TileLayer, renderer: TileLayerCanvasRenderer, tileImage: Tile['image'], tileInfo: Tile['info']) => void; + // tileRetryCount?: number; errorUrl?: string; customTags?: Record; decodeImageInWorker?: boolean; diff --git a/src/renderer/layer/tilelayer/TileLayerCanvasRenderer.ts b/src/renderer/layer/tilelayer/TileLayerCanvasRenderer.ts index 9a9636d066..044fce5a3f 100644 --- a/src/renderer/layer/tilelayer/TileLayerCanvasRenderer.ts +++ b/src/renderer/layer/tilelayer/TileLayerCanvasRenderer.ts @@ -841,14 +841,19 @@ class TileLayerCanvasRenderer extends CanvasRenderer { if (!this.layer) { return; } - tileImage.onerrorTick = tileImage.onerrorTick || 0; - const tileRetryCount = this.layer.options['tileRetryCount']; - if (tileRetryCount > tileImage.onerrorTick) { - tileImage.onerrorTick++; - this._fetchImage(tileImage, tileInfo); - this.removeTileLoading(tileInfo); + const reloadErrorTileFunction = this.layer.options['reloadErrorTileFunction']; + if (reloadErrorTileFunction) { + reloadErrorTileFunction.call(this, this.layer, this, tileInfo, tileImage); return; } + // tileImage.onerrorTick = tileImage.onerrorTick || 0; + // const tileRetryCount = this.layer.options['tileRetryCount']; + // if (tileRetryCount > tileImage.onerrorTick) { + // tileImage.onerrorTick++; + // this._fetchImage(tileImage, tileInfo); + // this.removeTileLoading(tileInfo); + // return; + // } const errorUrl = this.layer.options['errorUrl']; if (errorUrl) { if ((tileImage instanceof Image) && tileImage.src !== errorUrl) { @@ -1401,7 +1406,7 @@ export type TileImage = (HTMLImageElement | HTMLCanvasElement | ImageBitmap) & { loadTime: number; glBuffer?: TileImageBuffer; texture?: TileImageTexture; - onerrorTick?: number; + // onerrorTick?: number; } export interface Tile {