diff --git a/web/client/utils/PrintUtils.js b/web/client/utils/PrintUtils.js index fe4e0b28c5f..0d0d9d10bbd 100644 --- a/web/client/utils/PrintUtils.js +++ b/web/client/utils/PrintUtils.js @@ -576,13 +576,13 @@ export const specCreators = { SERVICE: "WMS", REQUEST: "GetLegendGraphic", LAYER: layer.name, - LANGUAGE: spec.language || '', STYLE: layer.style || '', SCALE: spec.scale, ...getLegendIconsSize(spec, layer), LEGEND_OPTIONS: "forceLabels:" + (spec.forceLabels ? "on" : "") + ";fontAntialiasing:" + spec.antiAliasing + ";dpi:" + spec.legendDpi + ";fontStyle:" + (spec.bold && "bold" || (spec.italic && "italic") || '') + ";fontName:" + spec.fontFamily + ";fontSize:" + spec.fontSize, format: "image/png", - ...assign({}, layer.params) + ...(spec.language ? {LANGUAGE: spec.language} : {}), + ...layer?.params }) }) ] diff --git a/web/client/utils/__tests__/PrintUtils-test.js b/web/client/utils/__tests__/PrintUtils-test.js index 8c4ada4e7ae..ad9d53d65d9 100644 --- a/web/client/utils/__tests__/PrintUtils-test.js +++ b/web/client/utils/__tests__/PrintUtils-test.js @@ -395,6 +395,17 @@ describe('PrintUtils', () => { const specs = getMapfishLayersSpecification([layer], { projection: "EPSG:3857" }, {}, 'legend'); expect(specs).toExist(); expect(specs.length).toBe(1); + expect(specs[0].classes.length).toBe(1); + // legendURL is a GetLegendGraphic request + expect(specs[0].classes[0].icons[0].indexOf('GetLegendGraphic') !== -1).toBe(true); + // LANGUAGE, if not included, should not be a parameter of the legend URL + expect(specs[0].classes[0].icons[0].indexOf('LANGUAGE')).toBe(-1); + const specs2 = getMapfishLayersSpecification([layer], { projection: "EPSG:3857", language: 'de' }, {}, 'legend'); + expect(specs2).toExist(); + expect(specs2.length).toBe(1); + expect(specs2[0].classes.length).toBe(1); + // LANGUAGE, if included, should be a parameter of the legend URL + expect(specs2[0].classes[0].icons[0].indexOf('LANGUAGE=de')).toBeGreaterThan(0); }); it('toOpenLayers2Style for vector layer wich contains a FeatureCollection using the default style', () => { const style = toOpenLayers2Style(vectorWithFtCollInside, null, "FeatureCollection");