Skip to content

Commit 47752e3

Browse files
feedback
1 parent 0ed0e2e commit 47752e3

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

x-pack/plugins/maps/public/connected_components/mb_map/mb_map.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ export class MBMap extends Component<Props, State> {
208208
this._tileStatusTracker = new TileStatusTracker({
209209
mbMap,
210210
getCurrentLayerList: () => this.props.layerList,
211-
setAreTilesLoaded: (layerId: string, areTilesLoaded: boolean) => {
212-
this.props.setAreTilesLoaded(layerId, areTilesLoaded);
213-
},
211+
setAreTilesLoaded: this.props.setAreTilesLoaded,
214212
});
215213

216214
const tooManyFeaturesImageSrc =

x-pack/plugins/maps/public/connected_components/mb_map/tile_status_tracker.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function createMockMbDataEvent(mbSourceId: string, tileKey: string): unknown {
6464
key: tileKey,
6565
},
6666
},
67-
coord: {
68-
key: tileKey,
67+
source: {
68+
type: 'vector',
6969
},
7070
};
7171
}

x-pack/plugins/maps/public/connected_components/mb_map/tile_status_tracker.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
* 2.0.
66
*/
77

8-
import { Map as MapboxMap, MapDataEvent } from 'mapbox-gl';
8+
import { Map as MapboxMap, MapSourceDataEvent } from 'mapbox-gl';
99
import _ from 'lodash';
1010
import { ILayer } from '../../classes/layers/layer';
1111
import { SPATIAL_FILTERS_LAYER_ID } from '../../../common/constants';
1212

1313
interface MbTile {
1414
// references internal object from mapbox
15-
aborted?: true;
15+
aborted?: boolean;
1616
}
1717

1818
interface 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

Comments
 (0)