Skip to content

Commit 02a59af

Browse files
[fix]webmap getpopupInfos返回layerId 数组
1 parent dbfbac6 commit 02a59af

4 files changed

Lines changed: 14 additions & 67 deletions

File tree

src/common/mapping/WebMapV2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
196196
return item;
197197
});
198198
}
199-
return { ...popupInfo, layerId, elements };
199+
return { ...popupInfo, layerId: [layerId], elements, title: name };
200200
}
201201
if (enableFields) {
202202
const elements = enableFields.map((fieldName) => ({
203203
type: 'FIELD',
204204
fieldName,
205205
fieldCaption: fieldCaptions ? (fieldCaptions[fieldName] || fieldName) : fieldName
206206
}));
207-
return { elements, layerId, title: name };
207+
return { elements, layerId: [layerId], title: name };
208208
}
209209
return null;
210210
}).filter(item => item !== null);

src/common/mapping/WebMapV3.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,12 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
371371
})
372372
}
373373
if (catalogType === 'layer') {
374-
const { popupInfo, msDatasetId, layersContent = [] } = catalog;
374+
const { popupInfo, msDatasetId, title, layersContent } = catalog;
375375
if (popupInfo) {
376376
const popupInfoVal = this._getPopupInfoContent(popupInfo, msDatasetId);
377-
const infos = layersContent.map(layerId => {
378-
return {
379-
layerId,
380-
...cloneDeep(popupInfoVal)
381-
}
382-
})
383-
res.push(...infos);
377+
if (popupInfoVal) {
378+
res.push({...popupInfoVal, layerId: layersContent, title});
379+
}
384380
}
385381
}
386382
}

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4413,7 +4413,7 @@ it('add rangeLayer last end === fieldValue', (done) => {
44134413
}
44144414
],
44154415
title: '北京市(3)',
4416-
layerId: '北京市(3)'
4416+
layerId: ['北京市(3)']
44174417
},
44184418
{
44194419
elements: [
@@ -4427,7 +4427,7 @@ it('add rangeLayer last end === fieldValue', (done) => {
44274427
}
44284428
],
44294429
title: '北京市轨道交通线路-打印(3)',
4430-
layerId: '北京市轨道交通线路-打印(3)'
4430+
layerId:[ '北京市轨道交通线路-打印(3)']
44314431
}
44324432
];
44334433
expect(popupInfo).toEqual(data);
@@ -4469,7 +4469,7 @@ it('add rangeLayer last end === fieldValue', (done) => {
44694469
}
44704470
],
44714471
title: '北京市轨道交通线路-打印(3)',
4472-
layerId: '北京市轨道交通线路-打印(3)'
4472+
layerId: ['北京市轨道交通线路-打印(3)']
44734473
}
44744474
];
44754475
expect(popupInfo).toEqual(data);
@@ -4550,7 +4550,7 @@ it('add rangeLayer last end === fieldValue', (done) => {
45504550
fieldCaption: 'acroutes'
45514551
}
45524552
],
4553-
layerId: '北京市(3)',
4553+
layerId:[ '北京市(3)'],
45544554
title: '北京市(3)'
45554555
},
45564556
{
@@ -4565,7 +4565,7 @@ it('add rangeLayer last end === fieldValue', (done) => {
45654565
}
45664566
],
45674567
title: '北京市轨道交通线路-打印(3)',
4568-
layerId: '北京市轨道交通线路-打印(3)'
4568+
layerId: ['北京市轨道交通线路-打印(3)']
45694569
}
45704570
];
45714571
expect(popupInfo).toEqual(data);

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ describe('mapboxgl-webmap3.0', () => {
17621762
}
17631763
],
17641764
title: 'A点',
1765-
layerId: 'A点'
1765+
layerId: ['A点']
17661766
},
17671767
{
17681768
elements: [
@@ -1810,59 +1810,10 @@ describe('mapboxgl-webmap3.0', () => {
18101810
}
18111811
],
18121812
title: 'A面',
1813-
layerId: 'A面'
1814-
},
1815-
{
1816-
elements: [
1817-
{
1818-
fieldName: 'geometry',
1819-
type: 'FIELD',
1820-
fieldCaption: 'geometry'
1821-
},
1822-
{
1823-
type: 'DIVIDER'
1824-
},
1825-
{
1826-
type: 'TEXT',
1827-
infos: [
1828-
{
1829-
insert: ['concat', '这是一段文本信息', ['get', 'smpid'], '\n']
1830-
}
1831-
]
1832-
},
1833-
{
1834-
type: 'DIVIDER'
1835-
},
1836-
{
1837-
type: 'IMAGE',
1838-
title: ['concat', '无标题', ['get', 'adcode'], '-图片'],
1839-
value: ['concat', ['get', 'adcode']]
1840-
},
1841-
{
1842-
type: 'IMAGE',
1843-
title: '无标题',
1844-
value: ['concat', ['get', 'adcode']]
1845-
},
1846-
{
1847-
type: 'VIDEO',
1848-
title: '无标题-视频',
1849-
value: 'https://www.runoob.com/try/demo_source/mov_bbb.mp4'
1850-
},
1851-
{
1852-
type: 'DIVIDER'
1853-
},
1854-
{
1855-
type: 'IMAGE',
1856-
title: ['concat', '无标题图片', ['get', 'adcode']],
1857-
value: ['concat', ['get', 'name'], ['get', 'smpid']]
1858-
}
1859-
],
1860-
title: 'A面',
1861-
layerId: 'A面1'
1813+
layerId: ['A面', 'A面1']
18621814
}
18631815
];
18641816
expect(popupInfo).toEqual(Data);
1865-
18661817
const popupInfo1 = mapstudioWebmap._handler._getPopupInfos({
18671818
catalogs: [
18681819
{
@@ -8424,7 +8375,7 @@ describe('mapboxgl-webmap3.0', () => {
84248375
]
84258376
});
84268377
const Data1 = {
8427-
layerId: 'Road_L@Jingjin#8(12_24)',
8378+
layerId: ['Road_L@Jingjin#8(12_24)'],
84288379
elements: [
84298380
{
84308381
fieldName: 'KD',

0 commit comments

Comments
 (0)