66
77import React from 'react' ;
88import { EuiIcon } from '@elastic/eui' ;
9- import { IVectorStyle , VectorStyle } from './styles/vector/vector_style' ;
9+ import { VectorStyle } from './styles/vector/vector_style' ;
1010import { SOURCE_DATA_ID_ORIGIN , LAYER_TYPE } from '../../common/constants' ;
1111import { VectorLayer , VectorLayerArguments } from './vector_layer' ;
1212import { canSkipSourceUpdate } from './util/can_skip_fetch' ;
13- import { ITiledSingleLayerVectorSource , IVectorSource } from './sources/vector_source' ;
13+ import { ITiledSingleLayerVectorSource } from './sources/vector_source' ;
1414import { SyncContext } from '../actions/map_actions' ;
1515import { ISource } from './sources/source' ;
16- import {
17- MapFilters ,
18- VectorLayerDescriptor ,
19- VectorSourceRequestMeta ,
20- } from '../../common/descriptor_types' ;
16+ import { VectorLayerDescriptor , VectorSourceRequestMeta } from '../../common/descriptor_types' ;
2117import { MVTSingleLayerVectorSourceConfig } from './sources/mvt_single_layer_vector_source/mvt_single_layer_vector_source_editor' ;
2218
2319export class TiledVectorLayer extends VectorLayer {
@@ -51,24 +47,6 @@ export class TiledVectorLayer extends VectorLayer {
5147 } ;
5248 }
5349
54- // _getSearchFilters(
55- // mapFilters: MapFilters,
56- // source: IVectorSource,
57- // style: IVectorStyle
58- // ): VectorSourceRequestMeta {
59- // const fieldNames = [...source.getFieldNames(), ...style.getSourceFieldNames()];
60- //
61- // const requestMeta: VectorSourceRequestMeta = {
62- // ...mapFilters,
63- // applyGlobalQuery: this._source.getApplyGlobalQuery(),
64- // sourceMeta: this._source.getSyncMeta(),
65- // fieldNames,
66- // sourceQuery: this.getQuery(),
67- // };
68- //
69- // return requestMeta;
70- // }
71-
7250 async _syncMVTUrlTemplate ( { startLoading, stopLoading, onLoadError, dataFilters } : SyncContext ) {
7351 const requestToken : symbol = Symbol ( `layer-${ this . getId ( ) } -${ SOURCE_DATA_ID_ORIGIN } ` ) ;
7452 const searchFilters : VectorSourceRequestMeta = this . _getSearchFilters (
@@ -147,13 +125,12 @@ export class TiledVectorLayer extends VectorLayer {
147125 return ;
148126 }
149127 const sourceMeta : MVTSingleLayerVectorSourceConfig = sourceDataRequest . getData ( ) as MVTSingleLayerVectorSourceConfig ;
150- const options = { mvtSourceLayer : sourceMeta . layerName } ;
151128
152- this . _setMbPointsProperties ( mbMap , options ) ;
153- this . _setMbLinePolygonProperties ( mbMap , options ) ;
129+ this . _setMbPointsProperties ( mbMap , sourceMeta . layerName ) ;
130+ this . _setMbLinePolygonProperties ( mbMap , sourceMeta . layerName ) ;
154131 }
155132
156- _requiresPrevSourceCleanup ( mbMap : unknown ) {
133+ _requiresPrevSourceCleanup ( mbMap : unknown ) : boolean {
157134 // @ts -ignore
158135 const mbTileSource = mbMap . getSource ( this . getId ( ) ) ;
159136 if ( ! mbTileSource ) {
@@ -177,26 +154,7 @@ export class TiledVectorLayer extends VectorLayer {
177154 }
178155
179156 syncLayerWithMB ( mbMap : unknown ) {
180- const requiresCleanup = this . _requiresPrevSourceCleanup ( mbMap ) ;
181- if ( requiresCleanup ) {
182- // @ts -ignore
183- const mbStyle = mbMap . getStyle ( ) ;
184- // @ts -ignore
185- mbStyle . layers . forEach ( mbLayer => {
186- if ( this . ownsMbLayerId ( mbLayer . id ) ) {
187- // @ts -ignore
188- mbMap . removeLayer ( mbLayer . id ) ;
189- }
190- } ) ;
191- // @ts -ignore
192- Object . keys ( mbStyle . sources ) . some ( mbSourceId => {
193- if ( this . ownsMbSourceId ( mbSourceId ) ) {
194- // @ts -ignore
195- mbMap . removeSource ( mbSourceId ) ;
196- }
197- } ) ;
198- }
199-
157+ this . _removeStaleMbSourcesAndLayers ( mbMap ) ;
200158 this . _syncSourceBindingWithMb ( mbMap ) ;
201159 this . _syncStylePropertiesWithMb ( mbMap ) ;
202160 }
0 commit comments