Skip to content

Commit cbea477

Browse files
[fix]webmapv2 getpopupInfos无captions
1 parent 694b031 commit cbea477

File tree

3 files changed

+363
-1
lines changed

3 files changed

+363
-1
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
202202
const elements = enableFields.map((fieldName) => ({
203203
type: 'FIELD',
204204
fieldName,
205-
fieldCaption: fieldCaptions[fieldName] || fieldName
205+
fieldCaption: fieldCaptions ? fieldCaptions[fieldName] : fieldName
206206
}));
207207
return { elements, layerId, title: name };
208208
}

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,6 +4286,163 @@ describe('mapboxgl_WebMapV2', () => {
42864286
datavizWebmap.on('mapcreatesucceeded', callback);
42874287
datavizWebmap.on('map');
42884288
});
4289+
it('webmap2.0 popupinfo no captions', (done) => {
4290+
spyOn(FetchRequest, 'get').and.callFake((url) => {
4291+
if (url.indexOf('map.json') > -1) {
4292+
return Promise.resolve(new Response(JSON.stringify(Webmap2_popupInfo_no_captions)));
4293+
} else if (url.indexOf('1168691327/content.json?') > -1) {
4294+
return Promise.resolve(new Response(JSON.stringify(chart_content)));
4295+
} else if (url.indexOf('1371715657/content.json?') > -1) {
4296+
return Promise.resolve(new Response(JSON.stringify(layerData_geojson['POINT_GEOJSON'])));
4297+
} else if (url.indexOf('portal.json') > -1) {
4298+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
4299+
}
4300+
return Promise.resolve(new Response(JSON.stringify({})));
4301+
});
4302+
datavizWebmap = new WebMap('123', {
4303+
server: server
4304+
});
4305+
const callback = function () {
4306+
const popupInfo = datavizWebmap.getPopupInfos();
4307+
const data = [
4308+
{
4309+
elements: [
4310+
{
4311+
fieldName: 'parent',
4312+
type: 'FIELD',
4313+
fieldCaption: 'parent'
4314+
},
4315+
{
4316+
fieldName: 'adcode',
4317+
type: 'FIELD',
4318+
fieldCaption: 'adcode'
4319+
},
4320+
{
4321+
fieldName: 'level',
4322+
type: 'FIELD',
4323+
fieldCaption: 'level'
4324+
},
4325+
{
4326+
fieldName: 'childrenNum',
4327+
type: 'FIELD',
4328+
fieldCaption: 'childrenNum'
4329+
},
4330+
{
4331+
fieldName: 'smpid',
4332+
type: 'FIELD',
4333+
fieldCaption: 'smpid'
4334+
},
4335+
{
4336+
fieldName: 'centroid',
4337+
type: 'FIELD',
4338+
fieldCaption: 'centroid'
4339+
},
4340+
{
4341+
fieldName: 'center',
4342+
type: 'FIELD',
4343+
fieldCaption: 'center'
4344+
},
4345+
{
4346+
fieldName: 'subFeatureIndex',
4347+
type: 'FIELD',
4348+
fieldCaption: 'subFeatureIndex'
4349+
},
4350+
{
4351+
fieldName: 'name',
4352+
type: 'FIELD',
4353+
fieldCaption: 'name'
4354+
},
4355+
{
4356+
fieldName: 'acroutes',
4357+
type: 'FIELD',
4358+
fieldCaption: 'acroutes'
4359+
},
4360+
{
4361+
type: 'DIVIDER'
4362+
},
4363+
{
4364+
type: 'TEXT',
4365+
infos: [
4366+
{
4367+
insert: ['concat', ['get', 'level'], ['get', 'adcode'], '----'],
4368+
attributes: {
4369+
size: 'small',
4370+
color: '#4e35cc',
4371+
underline: true,
4372+
strike: true,
4373+
bold: true,
4374+
italic: true
4375+
}
4376+
},
4377+
{
4378+
insert: ['concat', ['get', 'childrenNum'], ['get', 'parent']],
4379+
attributes: {
4380+
size: 'small',
4381+
color: '#e01b4b'
4382+
}
4383+
},
4384+
{
4385+
insert: '\n',
4386+
attributes: {
4387+
align: 'center'
4388+
}
4389+
}
4390+
]
4391+
},
4392+
{
4393+
type: 'DIVIDER'
4394+
},
4395+
{
4396+
type: 'IMAGE',
4397+
title: ['concat', ['get', 'adcode']],
4398+
value: ['concat', ['get', 'parent']]
4399+
},
4400+
{
4401+
type: 'IMAGE',
4402+
title: 'afdfd',
4403+
value: ['concat', ['get', 'level']]
4404+
},
4405+
{
4406+
type: 'DIVIDER'
4407+
},
4408+
{
4409+
type: 'VIDEO',
4410+
title: 'fdsfs',
4411+
value: 'http://fake:8190/iportal/apps/mapstudio/edit.html'
4412+
},
4413+
{
4414+
type: 'DIVIDER'
4415+
},
4416+
{
4417+
type: 'IMAGE',
4418+
title: ['concat', ['get', 'parent'], ['get', 'adcode']],
4419+
value: ['concat', ['get', 'adcode'], ['get', 'level']]
4420+
}
4421+
],
4422+
title: '北京市(3)',
4423+
layerId: '北京市(3)'
4424+
},
4425+
{
4426+
elements: [
4427+
{
4428+
fieldName: 'SmID',
4429+
type: 'FIELD'
4430+
},
4431+
{
4432+
fieldName: '标准名称',
4433+
type: 'FIELD'
4434+
}
4435+
],
4436+
title: '北京市轨道交通线路-打印(3)',
4437+
layerId: '北京市轨道交通线路-打印(3)'
4438+
}
4439+
];
4440+
expect(popupInfo).toEqual(data);
4441+
done();
4442+
};
4443+
datavizWebmap.on('mapcreatesucceeded', callback);
4444+
datavizWebmap.on('map');
4445+
});
42894446
it('webmap2.0 popupinfo 没有配置弹窗', (done) => {
42904447
spyOn(FetchRequest, 'get').and.callFake((url) => {
42914448
if (url.indexOf('map.json') > -1) {

test/resources/WebMapV5.js

Lines changed: 205 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)