55 * 2.0.
66 */
77
8- import { Map as MapboxMap , MapDataEvent } from 'mapbox-gl' ;
8+ import { Map as MapboxMap , MapSourceDataEvent } from 'mapbox-gl' ;
99import _ from 'lodash' ;
1010import { ILayer } from '../../classes/layers/layer' ;
1111import { SPATIAL_FILTERS_LAYER_ID } from '../../../common/constants' ;
1212
1313interface MbTile {
1414 // references internal object from mapbox
15- aborted ?: true ;
15+ aborted ?: boolean ;
1616}
1717
1818interface Tile {
@@ -26,22 +26,24 @@ export class TileStatusTracker {
2626 private readonly _mbMap : MapboxMap ;
2727 private readonly _setAreTilesLoaded : ( layerId : string , areTilesLoaded : boolean ) => void ;
2828 private readonly _getCurrentLayerList : ( ) => ILayer [ ] ;
29- private readonly _onSourceDataLoading = ( e : MapDataEvent & { sourceId : string } ) => {
29+ private readonly _onSourceDataLoading = ( e : MapSourceDataEvent ) => {
3030 if (
3131 e . sourceId &&
3232 e . sourceId !== SPATIAL_FILTERS_LAYER_ID &&
3333 e . dataType === 'source' &&
34- e . tile
34+ e . tile &&
35+ ( e . source . type === 'vector' || e . source . type === 'raster' )
3536 ) {
3637 const tracked = this . _tileCache . find ( ( tile ) => {
3738 return (
38- tile . mbKey === ( ( e . coord . key as unknown ) as string ) && tile . mbSourceId === e . sourceId
39+ tile . mbKey === ( ( e . tile . tileID . key as unknown ) as string ) &&
40+ tile . mbSourceId === e . sourceId
3941 ) ;
4042 } ) ;
4143
4244 if ( ! tracked ) {
4345 this . _tileCache . push ( {
44- mbKey : ( e . coord . key as unknown ) as string ,
46+ mbKey : ( e . tile . tileID . key as unknown ) as string ,
4547 mbSourceId : e . sourceId ,
4648 mbTile : e . tile ,
4749 } ) ;
@@ -50,19 +52,25 @@ export class TileStatusTracker {
5052 }
5153 } ;
5254
53- private readonly _onError = ( e : MapDataEvent & { sourceId : string ; tile : MbTile } ) => {
54- if ( e . sourceId && e . sourceId !== SPATIAL_FILTERS_LAYER_ID && e . tile ) {
55- this . _removeTileFromCache ( e . sourceId , e . tile . tileID . key ) ;
55+ private readonly _onError = ( e : MapSourceDataEvent ) => {
56+ if (
57+ e . sourceId &&
58+ e . sourceId !== SPATIAL_FILTERS_LAYER_ID &&
59+ e . tile &&
60+ ( e . source . type === 'vector' || e . source . type === 'raster' )
61+ ) {
62+ this . _removeTileFromCache ( e . sourceId , ( e . tile . tileID . key as unknown ) as string ) ;
5663 }
5764 } ;
58- private readonly _onSourceData = ( e : MapDataEvent & { sourceId : string } ) => {
65+ private readonly _onSourceData = ( e : MapSourceDataEvent ) => {
5966 if (
6067 e . sourceId &&
6168 e . sourceId !== SPATIAL_FILTERS_LAYER_ID &&
6269 e . dataType === 'source' &&
63- e . tile
70+ e . tile &&
71+ ( e . source . type === 'vector' || e . source . type === 'raster' )
6472 ) {
65- this . _removeTileFromCache ( e . sourceId , ( e . coord . key as unknown ) as string ) ;
73+ this . _removeTileFromCache ( e . sourceId , ( e . tile . tileID . key as unknown ) as string ) ;
6674 }
6775 } ;
6876
0 commit comments