Skip to content

Commit 257cc45

Browse files
committed
【feature】经纬网的webmap 加载完成标识优化,setLayoutProperty 优化;
1 parent eb8c806 commit 257cc45

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
213213
}
214214
this.expectLayerLen += overLayers.length;
215215
}
216+
if (mapInfo.grid && mapInfo.grid.graticule) {
217+
this.expectLayerLen++;
218+
}
216219
}
217220

218221
_shouldLoadBaseLayer(mapInfo, layerFilter) {
@@ -506,6 +509,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
506509
parentLayerId: graticuleLayer.id,
507510
subRenderLayers: [{ layerId: graticuleLayer.id }, { layerId: graticuleLayer.sourceId }]
508511
});
512+
this._addLayerSucceeded();
509513
}
510514

511515
_createGraticuleOptions(graticuleInfo) {

src/common/util/MapExtend.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ export function createMapExtendExtending(product) {
9595
if (overlayLayer.setLayoutProperty) {
9696
overlayLayer.setLayoutProperty(name, value);
9797
this.style.fire('data', { dataType: 'style' });
98+
} else if (name === 'visibility' && overlayLayer.setVisibility) {
99+
overlayLayer.setVisibility(value === 'visible');
100+
this.style.fire('data', { dataType: 'style' });
98101
}
99102
return this;
100103
}

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ describe('mapboxgl_WebMapV2', () => {
507507
};
508508
datavizWebmap.map.fire('zoomend');
509509
expect(data).not.toBeUndefined();
510+
expect(data.layers.slice(-1)[0].id).toContain('graticuleLayer_');
510511
done();
511512
};
512513
datavizWebmap = new WebMap(id, { ...commonOption });

test/mapboxgl/overlay/GraticuleLayerSpec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ describe('mapboxgl_GraticuleLayer', () => {
8282
expect(visible).toBe('visible');
8383
});
8484

85+
it('setLayoutProperty', () => {
86+
let visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
87+
expect(visible).toBe('visible');
88+
expect(graticuleLayer.visible).toBeTruthy();
89+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'none');
90+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
91+
expect(visible).toBe('none');
92+
expect(graticuleLayer.visible).toBeFalsy();
93+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'visible');
94+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
95+
expect(visible).toBe('visible');
96+
expect(graticuleLayer.visible).toBeTruthy();
97+
});
98+
8599
it('setMinZoom', () => {
86100
graticuleLayer.setMinZoom(0);
87101
expect(graticuleLayer.options.minZoom).toEqual(0);

test/maplibregl/mapping/WebMapV2Spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ describe('maplibregl_WebMapV2', () => {
508508
};
509509
datavizWebmap.map.fire('zoomend');
510510
expect(data).not.toBeUndefined();
511+
expect(data.layers.slice(-1)[0].id).toContain('graticuleLayer_');
511512
done();
512513
};
513514
datavizWebmap = new WebMap(id, { ...commonOption });

test/maplibregl/overlay/GraticuleLayerSpec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ describe('maplibregl_GraticuleLayer', () => {
8484
expect(visible).toBe('visible');
8585
});
8686

87+
it('setLayoutProperty', () => {
88+
let visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
89+
expect(visible).toBe('visible');
90+
expect(graticuleLayer.visible).toBeTruthy();
91+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'none');
92+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
93+
expect(visible).toBe('none');
94+
expect(graticuleLayer.visible).toBeFalsy();
95+
map.setLayoutProperty(graticuleLayer.id, 'visibility', 'visible');
96+
visible = map.getLayoutProperty('graticuleLayer_1_line', 'visibility');
97+
expect(visible).toBe('visible');
98+
expect(graticuleLayer.visible).toBeTruthy();
99+
});
100+
87101
it('getDefaultExtent must return degree', () => {
88102
map.getCRS = () => {
89103
return {

0 commit comments

Comments
 (0)