Skip to content

Commit 7000e5a

Browse files
[fix]点选弹窗ms自定义符号不对
1 parent 92af62e commit 7000e5a

File tree

3 files changed

+76
-16
lines changed

3 files changed

+76
-16
lines changed

src/common/mapping/WebMapV3.js

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { FetchRequest } from '../util/FetchRequest';
55
import { getLayerCatalogRenderLayers, getLayerInfosFromCatalogs, getMainLayerFromCatalog, isSameRasterLayer, mergeFeatures, transformUrl } from './utils/util';
66
import { SourceListModelV3 } from './utils/SourceListModelV3';
7+
import cloneDeep from 'lodash.clonedeep';
78

89
const LEGEND_RENDER_TYPE = {
910
TEXT: 'TEXT',
@@ -348,25 +349,36 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
348349
});
349350
return fieldCaptions;
350351
}
352+
_getPopupInfoContent(data, msDatasetId) {
353+
const popupInfo = cloneDeep(data);
354+
const fieldCaptions = this._getFieldCaption(msDatasetId);
355+
if (fieldCaptions) {
356+
popupInfo.elements = popupInfo.elements ? popupInfo.elements.map(item => {
357+
if (item.type === 'FIELD') {
358+
item.fieldCaption = fieldCaptions[item.fieldName] || item.fieldName;
359+
}
360+
return item;
361+
}) : [];
362+
}
363+
return popupInfo;
364+
}
351365
_getPopupInfos() {
352366
const { catalogs = [] } = this._mapResourceInfo;
353-
return catalogs.map((item) => {
354-
const {id, popupInfo, msDatasetId} = item;
367+
const res = [];
368+
catalogs.forEach((item) => {
369+
const {popupInfo, msDatasetId, layersContent=[]} = item;
355370
if (popupInfo) {
356-
const fieldCaptions = this._getFieldCaption(msDatasetId);
357-
if (fieldCaptions) {
358-
popupInfo.elements = popupInfo.elements ? popupInfo.elements.map(item => {
359-
if (item.type === 'FIELD') {
360-
item.fieldCaption = fieldCaptions[item.fieldName] || item.fieldName;
361-
}
362-
return item;
363-
}) : [];
364-
}
365-
popupInfo.layerId = id;
366-
return popupInfo
371+
const popupInfoVal = this._getPopupInfoContent(popupInfo, msDatasetId);
372+
const infos = layersContent.map(layerId => {
373+
return {
374+
layerId,
375+
...cloneDeep(popupInfoVal)
376+
}
377+
})
378+
res.push(...infos);
367379
}
368-
return null
369-
}).filter(item => item !== null);
380+
})
381+
return res;
370382
}
371383

372384
/**

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,54 @@ describe('mapboxgl-webmap3.0', () => {
17411741
],
17421742
title: 'A面',
17431743
layerId: 'A面'
1744+
},
1745+
{
1746+
elements: [
1747+
{
1748+
fieldName: 'geometry',
1749+
type: 'FIELD',
1750+
fieldCaption: 'geometry'
1751+
},
1752+
{
1753+
type: 'DIVIDER'
1754+
},
1755+
{
1756+
type: 'TEXT',
1757+
infos: [
1758+
{
1759+
insert: ['concat', '这是一段文本信息', ['get', 'smpid'], '\n']
1760+
}
1761+
]
1762+
},
1763+
{
1764+
type: 'DIVIDER'
1765+
},
1766+
{
1767+
type: 'IMAGE',
1768+
title: ['concat', '无标题', ['get', 'adcode'], '-图片'],
1769+
value: ['concat', ['get', 'adcode']]
1770+
},
1771+
{
1772+
type: 'IMAGE',
1773+
title: '无标题',
1774+
value: ['concat', ['get', 'adcode']]
1775+
},
1776+
{
1777+
type: 'VIDEO',
1778+
title: '无标题-视频',
1779+
value: 'https://www.runoob.com/try/demo_source/mov_bbb.mp4'
1780+
},
1781+
{
1782+
type: 'DIVIDER'
1783+
},
1784+
{
1785+
type: 'IMAGE',
1786+
title: ['concat', '无标题图片', ['get', 'adcode']],
1787+
value: ['concat', ['get', 'name'], ['get', 'smpid']]
1788+
}
1789+
],
1790+
title: 'A面',
1791+
layerId: 'A面1'
17441792
}
17451793
];
17461794
expect(popupInfo).toEqual(Data);

test/resources/WebMapV3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3894,7 +3894,7 @@ const msPopupInfo = JSON.stringify({
38943894
title: 'A面',
38953895
layerSourceType: 'Data',
38963896
zoomRange: [0, 24],
3897-
layersContent: ['A面']
3897+
layersContent: ['A面', 'A面1']
38983898
}
38993899
],
39003900
datas: [

0 commit comments

Comments
 (0)