Skip to content

Commit

Permalink
[fix]经纬网加入_cachelayerid, sourcelist更正
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Sep 10, 2024
1 parent 6473ea7 commit fc56700
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/mapboxgl/web-map/SourceListModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SourceListModel {
this.sourceNames = [];
this._initLayers();
this._initSource();
this.excludeSourceNames = ['tdt-search-', 'tdt-route-', 'smmeasure', 'mapbox-gl-draw'];
this.excludeSourceNames = ['tdt-search-', 'tdt-route-', 'smmeasure', 'mapbox-gl-draw', /graticuleLayer_\d+_line/];
}

getSourceList() {
Expand All @@ -37,7 +37,7 @@ class SourceListModel {

excludeSource(key) {
for (let i = 0; i < this.excludeSourceNames.length; i++) {
if (key.indexOf(this.excludeSourceNames[i]) >= 0) {
if (key && key.match(this.excludeSourceNames[i])) {
return false;
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ class SourceListModel {
if (overlayer.id) {
this.detailLayers.push({
id: overlayer.id,
visibility: overlayer.visibility ? 'visible' : 'none',
visibility: overlayer.visibility || overlayer.visible ? 'visible' : 'none',
source: overlayer.id
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ export default class WebMapViewModel extends WebMapBase {
const options = this._createGraticuleOptions(graticuleInfo);
const graticuleLayers = new mapboxgl.supermap.GraticuleLayer(options);
this.map.addLayer(graticuleLayers);
this._cacheLayerId.push(graticuleLayers.id);
this._setGraticuleDash(graticuleInfo.lineDash, graticuleLayers);
this._addLayerSucceeded();
}
Expand Down Expand Up @@ -2369,7 +2370,6 @@ export default class WebMapViewModel extends WebMapBase {
}

private _sendMapToUser(count: number, layersLen: number): void {
console.log('_sendMapToUser', count, layersLen)
if (count === layersLen) {
/**
* @event WebMapViewModel#addlayerssucceeded
Expand Down
2 changes: 2 additions & 0 deletions src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ describe('WebMapViewModel.spec', () => {
expect(data).not.toBeUndefined();
// 经纬网叠加完成后, 才触发addlayerssucceeded
expect(viewModel.expectLayerLen).toBe(3);
expect(viewModel._cacheLayerId.length).toBe(3);
expect(Object.keys(viewModel._sourceListModel.getSourceList()).length).toBe(3);
done();
};
const viewModel = new WebMapViewModel(id, { ...commonOption });
Expand Down
2 changes: 2 additions & 0 deletions test/unit/mocks/supermap_mapboxgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ supermap.Util = {

supermap.GraticuleLayer = () => {
return {
id: 'graticuleLayer_1',
visible: true,
setStrokeStyle: jest.fn()
}
};
Expand Down

0 comments on commit fc56700

Please sign in to comment.