Skip to content

Commit

Permalink
geosolutions-it#10711: using cfg loadFontAwesomeForIcons in root in l…
Browse files Browse the repository at this point in the history
…ocalConfig instead of map plugin and revert other changes
  • Loading branch information
mahmoudadel54 committed Dec 9, 2024
1 parent 51cd13c commit 9e72423
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 19 deletions.
3 changes: 1 addition & 2 deletions web/client/components/map/cesium/plugins/VectorLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion web/client/components/map/leaflet/plugins/VectorLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
9 changes: 3 additions & 6 deletions web/client/plugins/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -251,8 +249,7 @@ class MapPlugin extends React.Component {
items: [],
onLoadingMapPlugins: () => {},
onMapTypeLoaded: () => {},
pluginsCreator,
loadFontAwesomeForIcons: true
pluginsCreator
};

state = {};
Expand Down Expand Up @@ -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}
>
Expand Down
4 changes: 1 addition & 3 deletions web/client/utils/cesium/GeoJSONStyledFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions web/client/utils/styleparser/CesiumStyleParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/styleparser/OLStyleParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions web/client/utils/styleparser/StyleParserUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => [
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9e72423

Please sign in to comment.