Skip to content

Commit dbad778

Browse files
authored
Fixes #2608: custom mapOptions are not saved with maps (#2609)
1 parent 83d8717 commit dbad778

2 files changed

Lines changed: 266 additions & 1 deletion

File tree

web/client/utils/MapUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ function saveMapConfiguration(currentMap, currentLayers, currentGroups, textSear
333333
maxExtent: currentMap.maxExtent,
334334
projection: currentMap.projection,
335335
units: currentMap.units,
336-
zoom: currentMap.zoom
336+
zoom: currentMap.zoom,
337+
mapOptions: currentMap.mapOptions || {}
337338
};
338339

339340
const layers = currentLayers.map((layer) => {

web/client/utils/__tests__/MapUtils-test.js

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,269 @@ describe('Test the MapUtils', () => {
339339
visibility: true,
340340
catalogURL: "url"
341341
}],
342+
mapOptions: {},
343+
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
344+
projection: 'EPSG:900913',
345+
text_serch_config: '',
346+
units: 'm',
347+
zoom: 10
348+
},
349+
version: 2
350+
});
351+
});
352+
353+
it('save map configuration with map options', () => {
354+
const flat = [
355+
{
356+
allowedSRS: {},
357+
bbox: {},
358+
dimensions: [],
359+
id: "layer001",
360+
loading: true,
361+
name: "layer001",
362+
params: {},
363+
search: {},
364+
singleTile: false,
365+
thumbURL: "THUMB_URL",
366+
title: "layer001",
367+
type: "wms",
368+
url: "",
369+
visibility: true,
370+
catalogURL: "url"
371+
},
372+
{
373+
allowedSRS: {},
374+
bbox: {},
375+
dimensions: [],
376+
id: "layer002",
377+
loading: true,
378+
name: "layer002",
379+
params: {},
380+
search: {},
381+
singleTile: false,
382+
title: "layer002",
383+
type: "wms",
384+
url: "",
385+
visibility: true,
386+
catalogURL: "url"
387+
},
388+
{
389+
allowedSRS: {},
390+
bbox: {},
391+
dimensions: [],
392+
id: "layer003",
393+
loading: true,
394+
name: "layer003",
395+
params: {},
396+
search: {},
397+
singleTile: false,
398+
title: "layer003",
399+
type: "wms",
400+
url: "",
401+
visibility: true,
402+
catalogURL: "url"
403+
}
404+
];
405+
406+
const groups = [
407+
{ expanded: true, id: 'Default', name: 'Default', title: 'Default', nodes: ['layer001', 'layer002'] },
408+
{
409+
expanded: false, id: 'custom', name: 'custom', title: 'custom',
410+
nodes: [{ expanded: true, id: 'custom.nested001', name: 'nested001', title: 'nested001', nodes: ['layer003'] }
411+
]
412+
}
413+
];
414+
415+
const mapConfig = {
416+
center: { x: 0, y: 0, crs: 'EPSG:4326' },
417+
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
418+
projection: 'EPSG:900913',
419+
units: 'm',
420+
zoom: 10,
421+
mapOptions: {
422+
view: {
423+
resolutions: [
424+
84666.66666666688,
425+
42333.33333333344,
426+
21166.66666666672,
427+
10583.33333333336,
428+
5291.66666666668,
429+
2645.83333333334,
430+
1322.91666666667,
431+
661.458333333335000,
432+
529.166666666668000,
433+
396.875000000001000,
434+
264.583333333334000,
435+
132.291666666667000,
436+
66.145833333333500,
437+
39.687500000000100,
438+
26.458333333333400,
439+
13.229166666666700,
440+
6.614583333333350,
441+
3.968750000000010,
442+
2.645833333333340,
443+
1.322916666666670,
444+
0.661458333333335
445+
]
446+
}
447+
}
448+
};
449+
450+
const saved = saveMapConfiguration(mapConfig, flat, groups, '', {});
451+
expect(saved).toEqual({
452+
map: {
453+
center: { crs: 'EPSG:4326', x: 0, y: 0 },
454+
groups: [{
455+
id: 'Default',
456+
expanded: true
457+
}, {
458+
id: 'custom',
459+
expanded: false
460+
}, {
461+
id: 'custom.nested001',
462+
expanded: true
463+
}],
464+
layers: [{
465+
allowedSRS: {},
466+
thumbURL: "THUMB_URL",
467+
availableStyles: undefined,
468+
bbox: {},
469+
capabilitiesURL: undefined,
470+
description: undefined,
471+
dimensions: [],
472+
nativeCrs: undefined,
473+
features: undefined,
474+
featureInfo: undefined,
475+
format: undefined,
476+
group: undefined,
477+
hideLoading: false,
478+
handleClickOnLayer: false,
479+
id: "layer001",
480+
matrixIds: undefined,
481+
maxZoom: undefined,
482+
maxNativeZoom: undefined,
483+
name: "layer001",
484+
opacity: undefined,
485+
params: {},
486+
provider: undefined,
487+
search: {},
488+
singleTile: false,
489+
source: undefined,
490+
style: undefined,
491+
styleName: undefined,
492+
styles: undefined,
493+
tileMatrixSet: undefined,
494+
tiled: undefined,
495+
title: "layer001",
496+
transparent: undefined,
497+
type: "wms",
498+
url: "",
499+
visibility: true,
500+
catalogURL: "url"
501+
},
502+
{
503+
allowedSRS: {},
504+
thumbURL: undefined,
505+
availableStyles: undefined,
506+
bbox: {},
507+
capabilitiesURL: undefined,
508+
description: undefined,
509+
dimensions: [],
510+
nativeCrs: undefined,
511+
features: undefined,
512+
featureInfo: undefined,
513+
format: undefined,
514+
group: undefined,
515+
hideLoading: false,
516+
handleClickOnLayer: false,
517+
id: "layer002",
518+
matrixIds: undefined,
519+
maxZoom: undefined,
520+
maxNativeZoom: undefined,
521+
name: "layer002",
522+
opacity: undefined,
523+
params: {},
524+
provider: undefined,
525+
search: {},
526+
singleTile: false,
527+
source: undefined,
528+
style: undefined,
529+
styleName: undefined,
530+
styles: undefined,
531+
tileMatrixSet: undefined,
532+
tiled: undefined,
533+
title: "layer002",
534+
transparent: undefined,
535+
type: "wms",
536+
url: "",
537+
visibility: true,
538+
catalogURL: "url"
539+
},
540+
{
541+
allowedSRS: {},
542+
thumbURL: undefined,
543+
availableStyles: undefined,
544+
bbox: {},
545+
capabilitiesURL: undefined,
546+
description: undefined,
547+
dimensions: [],
548+
nativeCrs: undefined,
549+
features: undefined,
550+
featureInfo: undefined,
551+
format: undefined,
552+
group: undefined,
553+
hideLoading: false,
554+
handleClickOnLayer: false,
555+
id: "layer003",
556+
matrixIds: undefined,
557+
maxZoom: undefined,
558+
maxNativeZoom: undefined,
559+
name: "layer003",
560+
opacity: undefined,
561+
params: {},
562+
provider: undefined,
563+
search: {},
564+
singleTile: false,
565+
source: undefined,
566+
style: undefined,
567+
styleName: undefined,
568+
styles: undefined,
569+
tileMatrixSet: undefined,
570+
tiled: undefined,
571+
title: "layer003",
572+
transparent: undefined,
573+
type: "wms",
574+
url: "",
575+
visibility: true,
576+
catalogURL: "url"
577+
}],
578+
mapOptions: {
579+
view: {
580+
resolutions: [
581+
84666.66666666688,
582+
42333.33333333344,
583+
21166.66666666672,
584+
10583.33333333336,
585+
5291.66666666668,
586+
2645.83333333334,
587+
1322.91666666667,
588+
661.458333333335000,
589+
529.166666666668000,
590+
396.875000000001000,
591+
264.583333333334000,
592+
132.291666666667000,
593+
66.145833333333500,
594+
39.687500000000100,
595+
26.458333333333400,
596+
13.229166666666700,
597+
6.614583333333350,
598+
3.968750000000010,
599+
2.645833333333340,
600+
1.322916666666670,
601+
0.661458333333335
602+
]
603+
}
604+
},
342605
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
343606
projection: 'EPSG:900913',
344607
text_serch_config: '',
@@ -566,6 +829,7 @@ describe('Test the MapUtils', () => {
566829
visibility: true,
567830
catalogURL: "url"
568831
}],
832+
mapOptions: {},
569833
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
570834
projection: 'EPSG:900913',
571835
text_serch_config: '',

0 commit comments

Comments
 (0)