-
Notifications
You must be signed in to change notification settings - Fork 408
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
#10711: Control loading FontAwesome for vector style #10715
Conversation
Description: - add boolean cfg called 'loadFontAwesomeForIcons' for Map plugin to control the loading fontAwesome for vector style - add jsdocs in plugin/Map - handle the control of loading fontAwesome for openlayers, leaflet and cesium
…nd loadFontAwesomeForIcons = true --> it will load fontAwesome and if there is no icons ---> it won't load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check what i suggest here, also within the project as well
…ocalConfig instead of map plugin and revert other changes
const loadFontAwesomeForIcons = getConfigProp("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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MV88 @mahmoudadel54 in another branch I was exporting to loadingFontAwesome to a specific utils (this branch is not merged yet on master)
wouldn't it be better to expose a register function instead to have a loadFontAwesomeForIcons config?
let fontAwesomeLoaded = false;
export const isFontAwesomeReady = () => fontAwesomeLoaded;
let defaultLoadFontAwesome = () => {
if (fontAwesomeLoaded) {
return Promise.resolve();
}
// async load of font awesome
return import('font-awesome/css/font-awesome.min.css')
.then(() => {
// ensure the font is loaded
return document.fonts.load('1rem FontAwesome')
.then(() => {
fontAwesomeLoaded = true;
return fontAwesomeLoaded;
});
});
};
export const registerLoadFontAwesome = (promiseFunc) => {
defaultLoadFontAwesome = promiseFunc;
}
export const loadFontAwesome = () => {
return defaultLoadFontAwesome();
};
then in a specific project you could use registerLoadFontAwesome
in the app entry to override the default function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allyoucanmap
I think the use case we opened this issue is in importing vector layer. In import new vector layer -- > drawIcons method is called and it calls loadFontAwesome within it by default. We don't make exporting this specific method and use it particularly in import.
So I think your approach doesn't prevent calling this method because in import vector layer, calling this method is not optional.
@ElenaGallo can you test this on DEV asap? |
…eosolutions-it#10715) * geosolutions-it#10711: Control loading FontAwsome for vector style Description: - add boolean cfg called 'loadFontAwesomeForIcons' for Map plugin to control the loading fontAwesome for vector style - add jsdocs in plugin/Map - handle the control of loading fontAwesome for openlayers, leaflet and cesium * geosolutions-it#10711: enhance drawIcons if there are icons in data and loadFontAwesomeForIcons = true --> it will load fontAwesome and if there is no icons ---> it won't load * geosolutions-it#10711: using cfg loadFontAwesomeForIcons in root in localConfig instead of map plugin and revert other changes * geosolutions-it#10711: remove unused console.log in StylePArserUtils
Test passed, @mahmoudadel54 please backport. Thanks |
* #10711: Control loading FontAwsome for vector style Description: - add boolean cfg called 'loadFontAwesomeForIcons' for Map plugin to control the loading fontAwesome for vector style - add jsdocs in plugin/Map - handle the control of loading fontAwesome for openlayers, leaflet and cesium * #10711: enhance drawIcons if there are icons in data and loadFontAwesomeForIcons = true --> it will load fontAwesome and if there is no icons ---> it won't load * #10711: using cfg loadFontAwesomeForIcons in root in localConfig instead of map plugin and revert other changes * #10711: remove unused console.log in StylePArserUtils
Description
This PR handles control the loading of FontAwesome for vector data style.
A boolean cfg called 'loadFontAwesomeForIcons' for Map plugin can be added to control the loading fontAwesome for vector style this will be used for OpenLayers, Leaflet and Cesium. loadFontAwesomeForIcons is with true by default.
This PR enhances the loadFontAwesome function to load only if the vector data has icons.
This is a sample of config Map plugin:
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
#10711
What is the current behavior?
#10711
What is the new behavior?
If the Map plugin cfg contains loadFontAwesomeForIcons flag with false ---> so it will stop loading fontAwesome for vector data style and if with true -- > fontAwesome will be loaded in adding vector layer to map
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information