Skip to content

Commit

Permalink
【feature】数据查询结果清空结果source
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiaojiao committed Oct 15, 2024
1 parent 99f9953 commit a7efec9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/mapboxgl/_utils/HightlighLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import mapboxgl from 'vue-iclient/static/libs/mapboxgl/mapbox-gl-enhance';
import CircleStyle from 'vue-iclient/src/mapboxgl/_types/CircleStyle';
import LineStyle from 'vue-iclient/src/mapboxgl/_types/LineStyle';
import FillStyle from 'vue-iclient/src/mapboxgl/_types/FillStyle';
import { AnyLayer } from 'mapbox-gl';

interface HighlightStyle {
circle: InstanceType<typeof CircleStyle>;
Expand Down Expand Up @@ -110,6 +109,7 @@ export default class HighlightLayer extends mapboxgl.Evented {
filterFields?: string[];
clickTolerance = 5;
map: mapboxglTypes.Map;
fire: (type: string, params?: any) => void;

constructor(options: HighlightLayerOptions) {
super();
Expand Down Expand Up @@ -186,7 +186,7 @@ export default class HighlightLayer extends mapboxgl.Evented {
layout: Object.assign({}, LAYER_DEFAULT_STYLE[type].layout, layerStyle?.layout),
filter
});
this.map.addLayer(highlightLayer as AnyLayer);
this.map.addLayer(highlightLayer as mapboxglTypes.AnyLayer);
this.targetLayerIds.push(id);
this.targetLayerIds = this._uniqueLayerIds(this.targetLayerIds);
}
Expand All @@ -199,7 +199,7 @@ export default class HighlightLayer extends mapboxgl.Evented {
layout: Object.assign({}, LAYER_DEFAULT_STYLE['strokeLine'].layout, layerStyle?.layout),
filter
});
this.map.addLayer(highlightLayer as AnyLayer);
this.map.addLayer(highlightLayer as mapboxglTypes.AnyLayer);
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/mapboxgl/query/QueryViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ export default class QueryViewModel extends HighlightLayer {

clearResultLayer() {
if (this.map) {
this.strokeLayerID && this.map.getLayer(this.strokeLayerID) && this.map.removeLayer(this.strokeLayerID);
this.layerID && this.map.getLayer(this.layerID) && this.map.removeLayer(this.layerID);
this.removeHighlightLayers();
this.unregisterLayerMouseEvents();
const layerIds = [this.strokeLayerID, this.layerID].filter(item => !!item);
layerIds.forEach(item => {
if (this.map.getLayer(item)) {
this.map.removeLayer(item);
}
if (this.map.getSource(item)) {
this.map.removeSource(item);
}
});
}
}

Expand Down

0 comments on commit a7efec9

Please sign in to comment.