Skip to content

Commit

Permalink
fix DV地图开启自动更新,MD添加后更新无效 review by luox
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxianhuii committed Jun 21, 2024
1 parent cfc7929 commit ccdb87d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/mapboxgl/web-map/WebMapViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,9 @@ export default class WebMapViewModel extends WebMapBase {
};
if (!this.map.getSource(layerID)) {
this.map.addSource(layerID, source);
} else {
// @ts-ignore
this.map.getSource(layerID).setData(source.data);
}
const iconID = `imageIcon-${layerID}`;
if (style.type === 'IMAGE_POINT') {
Expand Down
45 changes: 45 additions & 0 deletions src/mapboxgl/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const commonMap = {
on: () => {},
fire: () => {},
setLayoutProperty: () => jest.fn(),
setPaintProperty: jest.fn(),
addStyle: () => jest.fn(),
remove: () => jest.fn(),
setRenderWorldCopies: () => jest.fn(),
Expand Down Expand Up @@ -1337,6 +1338,50 @@ describe('WebMapViewModel.spec', () => {
viewModel.on({ addlayerssucceeded: callback });
});

it('updateOverlayLayer GraphicLayer', done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData_CSV,
'https://fakeiportal.supermap.io/iportal/web/datas/13136933/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData_geojson['POINT_GEOJSON']
};
mockFetch(fetchResource);
const id = vectorLayer_point;
const viewModel = new WebMapViewModel(id, { ...commonOption }, undefined, { ...commonMap });
const callback = function (data) {
const sourceData1 = data.map.getSource('浙江省高等院校(3)')._data.features;
expect(sourceData1.length).toBe(2);
const layerInfo = { ...vectorLayer_point.layers[0], id: vectorLayer_point.layers[0].name };
const features = [
{
type: 'Feature',
properties: {
'机场': '上海/浦东',
'X坐标': '121.812361 ',
'Y坐标': '31.093992 ',
'名次': '2',
'2017旅客吞吐量(人次)': '70,001,237 ',
'2016旅客吞吐量(人次)': '66,002,414 ',
'同比增速%': '3.5 ',
'2017货邮吞吐量(吨)': '3,824,279.9 ',
'2016货邮吞吐量(吨)': '3,440,279.7 ',
'2017起降架次(架次)': '496,774 ',
'2016起降架次(架次)': '479,902 ',
index: 1
},
geometry: { type: 'Point', coordinates: [Array] }
}
]
const spy = jest.spyOn(viewModel, '_createGraphicLayer');
viewModel.updateOverlayLayer(layerInfo, features);
expect(spy).toBeCalled();
const sourceData2 = data.map.getSource('浙江省高等院校(3)')._data.features;
expect(sourceData2.length).toBe(1);
done();
};
viewModel.on({ addlayerssucceeded: callback });
});

it('add baselayer which is baidu', done => {
const callback = function (data) {
expect(data).not.toBeUndefined();
Expand Down

0 comments on commit ccdb87d

Please sign in to comment.