Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10279: Show credits/attribution text in printed page #10451

Merged
merged 4 commits into from
Jul 5, 2024
Prev Previous commit
Next Next commit
#100279: Show credits/attribution text in printed page (resolve revie…
…w comments)

Description:
- add PR link to migration guide file for the added section
- add js doc to 'parseCreditRemovingTagsOrSymbol' method
- simplified the method of 'getLayersCredits'
  • Loading branch information
mahmoudadel54 committed Jul 5, 2024
commit 8b652a3da455f23381485d4fb937d4b3131fedfb
2 changes: 1 addition & 1 deletion docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is a list of things to check if you want to update from a previous version

Due to showing layers' credits/attributions of printed map which will be displayed at the bottom of the map section, the MapStore `config.yaml` file should be reviewed and updated. Below are reported the relevant changes that need to be applied also to `config.yaml` of MapStore donwstream projects where the printing engine is present.
MV88 marked this conversation as resolved.
Show resolved Hide resolved

- Added a section for credits into config.yaml file at the end of the mainPage for each layout
- Added a section for credits into config.yaml file at the end of the mainPage for each layout, for more details see [here](https://github.com/geosolutions-it/MapStore2/pull/10451/files#diff-3599ba7c628c7c764665046828bad74c0c8576aad03f5497cf426b59010a6d07R27)
- In this added section, proper values for `absoluteX` and `absoluteY` should be applied to be consistent with overall layout
- There are some edits to the value of `absoluteY` for the section located directly above credit/attribution section based on the layout
mahmoudadel54 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
31 changes: 16 additions & 15 deletions web/client/utils/PrintUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ export const getMapSize = (layout, maxWidth) => {

export const mapProjectionSelector = (state) => state?.print?.map?.projection ?? "EPSG:3857";

/**
* Parse credit/attribution text by removing html tags within its text plus removing '|' symbol
* @param {string} creditText the layer credit/attribution text
* @returns {string} the parsed credit/attribution text after removing html tags plus '|' symbol within
* @memberof utils.PrintUtils
*/
export function parseCreditRemovingTagsOrSymbol(creditText = "") {
mahmoudadel54 marked this conversation as resolved.
Show resolved Hide resolved
let parsedCredit = creditText;
do {
Expand All @@ -251,21 +257,16 @@ export function parseCreditRemovingTagsOrSymbol(creditText = "") {
* @memberof utils.PrintUtils
*/
export const getLayersCredits = (layers) => {
const credits = layers.reduce((cum, lay) => {
let cumCredit = cum;
let layerCredit = lay?.credits?.title;
if (layerCredit) {
// remove tag <> and symbols like: |
let hasOrSymbol = layerCredit.includes('|');
const hasHtmlTag = layerCredit.includes('<');
if (hasHtmlTag || hasOrSymbol) {
layerCredit = parseCreditRemovingTagsOrSymbol(layerCredit);
}
cumCredit = cumCredit ? cumCredit + " | " + layerCredit : layerCredit;
}
return cumCredit;
}, '');
return credits;
const layerCredits = layers.map((layer) => {
const layerCreditTitle = layer?.credits?.title || '';
const hasOrSymbol = layerCreditTitle.includes('|');
const hasHtmlTag = layerCreditTitle.includes('<');
const layerCredit = (hasHtmlTag || hasOrSymbol)
? parseCreditRemovingTagsOrSymbol(layerCreditTitle)
: layerCreditTitle;
return layerCredit;
}).join(' | ');
return layerCredits;
};

/**
Expand Down
Loading