From 9e7242386ef4e0af7ced36b0eac4ae83aad95351 Mon Sep 17 00:00:00 2001 From: mahmoudadel54 Date: Mon, 9 Dec 2024 15:57:55 +0200 Subject: [PATCH] #10711: using cfg loadFontAwesomeForIcons in root in localConfig instead of map plugin and revert other changes --- web/client/components/map/cesium/plugins/VectorLayer.js | 3 +-- .../components/map/leaflet/plugins/VectorLayer.jsx | 2 +- .../components/map/openlayers/plugins/VectorLayer.js | 2 +- web/client/plugins/Map.jsx | 9 +++------ web/client/utils/cesium/GeoJSONStyledFeatures.js | 4 +--- web/client/utils/styleparser/CesiumStyleParser.js | 5 ++--- web/client/utils/styleparser/OLStyleParser.js | 2 +- web/client/utils/styleparser/StyleParserUtils.js | 8 ++++++-- 8 files changed, 16 insertions(+), 19 deletions(-) diff --git a/web/client/components/map/cesium/plugins/VectorLayer.js b/web/client/components/map/cesium/plugins/VectorLayer.js index 4a1ad72cf1..34fccd432b 100644 --- a/web/client/components/map/cesium/plugins/VectorLayer.js +++ b/web/client/components/map/cesium/plugins/VectorLayer.js @@ -33,8 +33,7 @@ const createLayer = (options, map) => { id: options?.id, map: map, opacity: options.opacity, - queryable: options.queryable === undefined || options.queryable, - loadFontAwesomeForIcons: options?.loadFontAwesomeForIcons + queryable: options.queryable === undefined || options.queryable }); layerToGeoStylerStyle(options) diff --git a/web/client/components/map/leaflet/plugins/VectorLayer.jsx b/web/client/components/map/leaflet/plugins/VectorLayer.jsx index 3e07e0e00b..2834bed845 100644 --- a/web/client/components/map/leaflet/plugins/VectorLayer.jsx +++ b/web/client/components/map/leaflet/plugins/VectorLayer.jsx @@ -60,7 +60,7 @@ const createLayer = (options) => { getStyle(applyDefaultStyleToVectorLayer(options), 'leaflet') .then((styleUtils) => { - styleUtils({ opacity: options.opacity, layer, features: options.features, loadFontAwesomeForIcons: options.loadFontAwesomeForIcons }) + styleUtils({ opacity: options.opacity, layer, features: options.features }) .then(({ style: styleFunc, pointToLayer = () => null, diff --git a/web/client/components/map/openlayers/plugins/VectorLayer.js b/web/client/components/map/openlayers/plugins/VectorLayer.js index c1f1a876ff..b85e404f90 100644 --- a/web/client/components/map/openlayers/plugins/VectorLayer.js +++ b/web/client/components/map/openlayers/plugins/VectorLayer.js @@ -43,7 +43,7 @@ Layers.registerType('vector', { .then((style) => { if (style) { if (style.__geoStylerStyle) { - style({ map, features: options.features, loadFontAwesomeForIcons: options.loadFontAwesomeForIcons }) + style({ map, features: options.features }) .then((olStyle) => { layer.setStyle(olStyle); }); diff --git a/web/client/plugins/Map.jsx b/web/client/plugins/Map.jsx index 7f0233d420..31e5bae4fb 100644 --- a/web/client/plugins/Map.jsx +++ b/web/client/plugins/Map.jsx @@ -162,7 +162,6 @@ import {getHighlightLayerOptions} from "../utils/HighlightUtils"; * @prop {boolean} mapOptions.cesium.depthTestAgainstTerrain if true all primitive 3d features will be tested against the terrain while if false they will be drawn on top of the terrain even if hidden by it (default true) * @prop {number} mapOptions.cesium.maximumZoomDistance max zoom limit (in meter unit) to restrict the zoom out operation based on it * @prop {number} mapOptions.cesium.minimumZoomDistance min zoom limit (in meter unit) to restrict the zoom in operation based on it - * @prop {boolean} loadFontAwesomeForIcons flag for control loading fontAwesome for vector layer style * @static * @example * // Adding a layer to be used as a source for the elevation (shown in the MousePosition plugin configured with showElevation = true) @@ -212,8 +211,7 @@ class MapPlugin extends React.Component { items: PropTypes.array, onLoadingMapPlugins: PropTypes.func, onMapTypeLoaded: PropTypes.func, - pluginsCreator: PropTypes.func, - loadFontAwesomeForIcons: PropTypes.bool + pluginsCreator: PropTypes.func }; static defaultProps = { @@ -251,8 +249,7 @@ class MapPlugin extends React.Component { items: [], onLoadingMapPlugins: () => {}, onMapTypeLoaded: () => {}, - pluginsCreator, - loadFontAwesomeForIcons: true + pluginsCreator }; state = {}; @@ -333,7 +330,7 @@ class MapPlugin extends React.Component { srs={projection} position={index} key={layer.id || layer.name} - options={{...layer, loadFontAwesomeForIcons: this.props.loadFontAwesomeForIcons}} + options={layer} securityToken={this.props.securityToken} env={env} > diff --git a/web/client/utils/cesium/GeoJSONStyledFeatures.js b/web/client/utils/cesium/GeoJSONStyledFeatures.js index 147e471b4c..541168c1bb 100644 --- a/web/client/utils/cesium/GeoJSONStyledFeatures.js +++ b/web/client/utils/cesium/GeoJSONStyledFeatures.js @@ -84,7 +84,6 @@ class GeoJSONStyledFeatures { this._dataSource.entities.collectionChanged.addEventListener(() => { setTimeout(() => this._map.scene.requestRender(), 300); }); - this.loadFontAwesomeForIcons = options.loadFontAwesomeForIcons; // internal key to associate features with original features this._uuidKey = '__ms_uuid_key__' + uuid(); // needs to be run after this._uuidKey @@ -370,8 +369,7 @@ class GeoJSONStyledFeatures { getPreviousStyledFeature: (styledFeature) => { const editingStyleFeature = this._styledFeatures.find(({ id }) => id === styledFeature.id); return editingStyleFeature; - }, - loadFontAwesomeForIcons: this.loadFontAwesomeForIcons + } }) .then((styledFeatures) => { this._updateEntities(styledFeatures, forceUpdate); diff --git a/web/client/utils/styleparser/CesiumStyleParser.js b/web/client/utils/styleparser/CesiumStyleParser.js index 9683ca0772..88040cf604 100644 --- a/web/client/utils/styleparser/CesiumStyleParser.js +++ b/web/client/utils/styleparser/CesiumStyleParser.js @@ -1036,10 +1036,9 @@ function getStyleFuncFromRules({ features, getPreviousStyledFeature = () => {}, map, - sampleTerrain = Cesium.sampleTerrain, - loadFontAwesomeForIcons + sampleTerrain = Cesium.sampleTerrain }) => { - return drawIcons({ rules, loadFontAwesomeForIcons }, { features }) + return drawIcons({ rules }, { features }) .then((images) => { const styledFeatures = getStyledFeatures({ rules, features, globalOpacity, images }); return Promise.all(styledFeatures.map((currentFeature) => { diff --git a/web/client/utils/styleparser/OLStyleParser.js b/web/client/utils/styleparser/OLStyleParser.js index c2e333a1d0..c6a5d6cb2a 100644 --- a/web/client/utils/styleparser/OLStyleParser.js +++ b/web/client/utils/styleparser/OLStyleParser.js @@ -425,7 +425,7 @@ export class OlStyleParser { */ geoStylerStyleToOlParserStyleFct(geoStylerStyle) { const rules = geoStylerStyle.rules; - const olStyle = ({ map, features, loadFontAwesomeForIcons } = {}) => drawIcons({...geoStylerStyle, loadFontAwesomeForIcons}, { features }) + const olStyle = ({ map, features } = {}) => drawIcons(geoStylerStyle, { features }) .then((images) => { this._getImages = () => images; this._getImageSrc = createGetImagesSrc(); diff --git a/web/client/utils/styleparser/StyleParserUtils.js b/web/client/utils/styleparser/StyleParserUtils.js index 9cd638f26f..7cdce6d62c 100644 --- a/web/client/utils/styleparser/StyleParserUtils.js +++ b/web/client/utils/styleparser/StyleParserUtils.js @@ -39,6 +39,7 @@ import isNil from 'lodash/isNil'; import isObject from 'lodash/isObject'; import MarkerUtils from '../MarkerUtils'; import {randomInt} from '../RandomUtils'; +import { getConfigProp } from '../ConfigUtils'; export const isGeoStylerBooleanFunction = (got) => [ @@ -917,8 +918,11 @@ export const drawIcons = (geoStylerStyle, options) => { }, []); const marks = symbolizers.filter(({ kind }) => kind === 'Mark'); const icons = symbolizers.filter(({ kind }) => kind === 'Icon'); - const shouldLoadFontAwesomeForIcons = (geoStylerStyle.loadFontAwesomeForIcons && icons.length > 0) ? loadFontAwesome() : Promise.resolve(); - return shouldLoadFontAwesomeForIcons + const loadFontAwesomeForIcons = getConfigProp("loadFontAwesomeForIcons"); + console.log({loadFontAwesomeForIcons}); + // if undefined or true it will load it to preserve previous behaviour + const loadingPromise = (isNil(loadFontAwesomeForIcons) || loadFontAwesomeForIcons) && icons?.length ? loadFontAwesome() : Promise.resolve(); + return loadingPromise .then( () => new Promise((resolve) => { if (marks.length > 0 || icons.length > 0) {