From fcc7c59ee75beccd4f03aa227bf73d515e115c23 Mon Sep 17 00:00:00 2001 From: MV88 Date: Wed, 25 Oct 2023 17:04:59 +0200 Subject: [PATCH 1/6] Fix #9653 embedded icons are correctly loaded --- .../mapstore-migration-guide.md | 9 + project/standard/templates/api.html | 1 + project/standard/templates/apiTemplate.html | 1 + .../dashboard-embedded-template.html | 1 + .../templates/dashboard-embedded.html | 1 + project/standard/templates/embedded.html | 1 + .../standard/templates/embeddedTemplate.html | 1 + .../templates/geostory-embedded-template.html | 1 + .../standard/templates/geostory-embedded.html | 1 + web/client/api.html | 1 + web/client/apiTemplate.html | 1 + web/client/dashboard-embedded-template.html | 1 + web/client/dashboard-embedded.html | 1 + web/client/embedded.html | 1 + web/client/embeddedTemplate.html | 1 + web/client/geostory-embedded-template.html | 1 + web/client/geostory-embedded.html | 1 + web/client/plugins/Map.jsx | 43 +-- web/client/plugins/map/selector.js | 4 +- web/client/utils/AgentUtils.js | 325 ------------------ 20 files changed, 29 insertions(+), 368 deletions(-) diff --git a/docs/developer-guide/mapstore-migration-guide.md b/docs/developer-guide/mapstore-migration-guide.md index 85cf9b5455..28b1553409 100644 --- a/docs/developer-guide/mapstore-migration-guide.md +++ b/docs/developer-guide/mapstore-migration-guide.md @@ -22,6 +22,15 @@ This is a list of things to check if you want to update from a previous version ## Migration from 2023.02.xx to 2024.01.00 +### Removing possibility to add custom fonts to the Map + +From this version we limited the load of the font to FontAwesome. + +If you have changed the property **fonts** inside Map plugin it will not longer load the font. A possible fix would be to add the font to the `*.html` files in your application. + +- make sure that the `localConfig.json` does not have **fonts** property in **Map** plugin +- add `` inside the *head* tag for every .html file you have in your project + ### Fixing background config From this version in order to fix default 3d background config a change is needed here: diff --git a/project/standard/templates/api.html b/project/standard/templates/api.html index c568fcd4f6..bd557fca4e 100644 --- a/project/standard/templates/api.html +++ b/project/standard/templates/api.html @@ -8,6 +8,7 @@ + + diff --git a/project/standard/templates/geostory-embedded-template.html b/project/standard/templates/geostory-embedded-template.html index 390bdd0a28..7306e03d6e 100644 --- a/project/standard/templates/geostory-embedded-template.html +++ b/project/standard/templates/geostory-embedded-template.html @@ -95,6 +95,7 @@ + diff --git a/web/client/geostory-embedded-template.html b/web/client/geostory-embedded-template.html index 481840792f..99161c18ca 100644 --- a/web/client/geostory-embedded-template.html +++ b/web/client/geostory-embedded-template.html @@ -95,6 +95,7 @@ + diff --git a/project/standard/templates/geostory-embedded-template.html b/project/standard/templates/geostory-embedded-template.html index 7306e03d6e..0df4efab31 100644 --- a/project/standard/templates/geostory-embedded-template.html +++ b/project/standard/templates/geostory-embedded-template.html @@ -95,7 +95,7 @@ - + diff --git a/web/client/api.html b/web/client/api.html index 95e125f357..cd375da58c 100644 --- a/web/client/api.html +++ b/web/client/api.html @@ -7,7 +7,7 @@ Page with MapStore API - + diff --git a/web/client/apiTemplate.html b/web/client/apiTemplate.html index bcc228a028..03bb32810d 100644 --- a/web/client/apiTemplate.html +++ b/web/client/apiTemplate.html @@ -7,7 +7,7 @@ Page with MapStore API - + diff --git a/web/client/dashboard-embedded-template.html b/web/client/dashboard-embedded-template.html index 4923ed8d60..82f5a3cc77 100644 --- a/web/client/dashboard-embedded-template.html +++ b/web/client/dashboard-embedded-template.html @@ -95,7 +95,7 @@ - + diff --git a/web/client/geostory-embedded-template.html b/web/client/geostory-embedded-template.html index 99161c18ca..41c158af90 100644 --- a/web/client/geostory-embedded-template.html +++ b/web/client/geostory-embedded-template.html @@ -95,7 +95,7 @@ - + diff --git a/web/client/utils/styleparser/StyleParserUtils.js b/web/client/utils/styleparser/StyleParserUtils.js index 21252393cb..b77a911df6 100644 --- a/web/client/utils/styleparser/StyleParserUtils.js +++ b/web/client/utils/styleparser/StyleParserUtils.js @@ -853,6 +853,26 @@ export const parseSymbolizerExpressions = (symbolizer, feature) => { }; +const loadFontAwesome = () => { + return new Promise((resolve) => { + const fontAwesomeHref = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'; + if (!document.querySelector(`link[href='${fontAwesomeHref}']`)) { + const fontAwesome = document.createElement('link'); + fontAwesome.setAttribute('rel', 'stylesheet'); + fontAwesome.setAttribute('href', fontAwesomeHref); + document.head.appendChild(fontAwesome); + fontAwesome.onload = () => { + resolve(); + }; + fontAwesome.onerror = () => { + resolve(); + }; + } else { + resolve(); + } + }); +}; + /** * prefetch all image or mark symbol in a geostyler style * @param {object} geoStylerStyle geostyler style @@ -886,16 +906,19 @@ export const drawIcons = (geoStylerStyle, options) => { }, []); const marks = symbolizers.filter(({ kind }) => kind === 'Mark'); const icons = symbolizers.filter(({ kind }) => kind === 'Icon'); - return new Promise((resolve) => { - if (marks.length > 0 || icons.length > 0) { - Promise.all([ - ...marks.map(getWellKnownNameImageFromSymbolizer), - ...icons.map(getImageFromSymbolizer) - ]).then((images) => { - resolve(images); - }); - } else { - resolve([]); - } - }); + return loadFontAwesome() + .then( + () => new Promise((resolve) => { + if (marks.length > 0 || icons.length > 0) { + Promise.all([ + ...marks.map(getWellKnownNameImageFromSymbolizer), + ...icons.map(getImageFromSymbolizer) + ]).then((images) => { + resolve(images); + }); + } else { + resolve([]); + } + }) + ); }; From 53d7eae1fe16840a167d77942b4c33ec8a125512 Mon Sep 17 00:00:00 2001 From: MV88 Date: Wed, 15 Nov 2023 15:28:02 +0100 Subject: [PATCH 4/6] fix indentation --- project/standard/templates/dashboard-embedded.html | 1 - project/standard/templates/embedded.html | 1 - project/standard/templates/embeddedTemplate.html | 1 - project/standard/templates/index.html | 1 - web/client/api.html | 1 - web/client/apiTemplate.html | 1 - web/client/dashboard-embedded-template.html | 1 - web/client/dashboard-embedded.html | 1 - web/client/embedded.html | 1 - web/client/embeddedTemplate.html | 1 - web/client/index.html | 1 - 11 files changed, 11 deletions(-) diff --git a/project/standard/templates/dashboard-embedded.html b/project/standard/templates/dashboard-embedded.html index 4b48410f24..dec64c1ba4 100644 --- a/project/standard/templates/dashboard-embedded.html +++ b/project/standard/templates/dashboard-embedded.html @@ -95,7 +95,6 @@ - diff --git a/project/standard/templates/embedded.html b/project/standard/templates/embedded.html index ad8ec5bd54..c59bc561fb 100644 --- a/project/standard/templates/embedded.html +++ b/project/standard/templates/embedded.html @@ -85,7 +85,6 @@ - diff --git a/project/standard/templates/embeddedTemplate.html b/project/standard/templates/embeddedTemplate.html index d889caba84..d957ca5f12 100644 --- a/project/standard/templates/embeddedTemplate.html +++ b/project/standard/templates/embeddedTemplate.html @@ -85,7 +85,6 @@ - diff --git a/project/standard/templates/index.html b/project/standard/templates/index.html index d8ca4bb132..de360edd75 100644 --- a/project/standard/templates/index.html +++ b/project/standard/templates/index.html @@ -84,7 +84,6 @@ - diff --git a/web/client/api.html b/web/client/api.html index cd375da58c..1d77ffb558 100644 --- a/web/client/api.html +++ b/web/client/api.html @@ -7,7 +7,6 @@ Page with MapStore API - diff --git a/web/client/apiTemplate.html b/web/client/apiTemplate.html index 03bb32810d..c908c6fce1 100644 --- a/web/client/apiTemplate.html +++ b/web/client/apiTemplate.html @@ -7,7 +7,6 @@ Page with MapStore API - diff --git a/web/client/dashboard-embedded-template.html b/web/client/dashboard-embedded-template.html index 82f5a3cc77..b663515ffa 100644 --- a/web/client/dashboard-embedded-template.html +++ b/web/client/dashboard-embedded-template.html @@ -95,7 +95,6 @@ - diff --git a/web/client/index.html b/web/client/index.html index 1b7700ea7e..d7f952eaf2 100644 --- a/web/client/index.html +++ b/web/client/index.html @@ -84,7 +84,6 @@ - From a560867062a2851868261246e1c9f64caae3e4ef Mon Sep 17 00:00:00 2001 From: MV88 Date: Wed, 15 Nov 2023 15:28:13 +0100 Subject: [PATCH 5/6] fix migration guide --- docs/developer-guide/mapstore-migration-guide.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/developer-guide/mapstore-migration-guide.md b/docs/developer-guide/mapstore-migration-guide.md index 28b1553409..b7592d8ccb 100644 --- a/docs/developer-guide/mapstore-migration-guide.md +++ b/docs/developer-guide/mapstore-migration-guide.md @@ -29,7 +29,8 @@ From this version we limited the load of the font to FontAwesome. If you have changed the property **fonts** inside Map plugin it will not longer load the font. A possible fix would be to add the font to the `*.html` files in your application. - make sure that the `localConfig.json` does not have **fonts** property in **Map** plugin -- add `` inside the *head* tag for every .html file you have in your project + +The following css is added automatically if needed `` inside the *head* tag. ### Fixing background config From 627934584db708e607c8b16ed569dde9cb39b4c9 Mon Sep 17 00:00:00 2001 From: MV88 Date: Wed, 15 Nov 2023 15:31:02 +0100 Subject: [PATCH 6/6] Fix indentation again --- project/standard/templates/geostory-embedded-template.html | 1 - project/standard/templates/geostory-embedded.html | 1 - project/standard/templates/indexTemplate.html | 1 - web/client/geostory-embedded-template.html | 1 - web/client/geostory-embedded.html | 1 - web/client/indexTemplate.html | 1 - 6 files changed, 6 deletions(-) diff --git a/project/standard/templates/geostory-embedded-template.html b/project/standard/templates/geostory-embedded-template.html index 0df4efab31..390bdd0a28 100644 --- a/project/standard/templates/geostory-embedded-template.html +++ b/project/standard/templates/geostory-embedded-template.html @@ -95,7 +95,6 @@ - diff --git a/web/client/geostory-embedded-template.html b/web/client/geostory-embedded-template.html index 41c158af90..481840792f 100644 --- a/web/client/geostory-embedded-template.html +++ b/web/client/geostory-embedded-template.html @@ -95,7 +95,6 @@ -