-
Notifications
You must be signed in to change notification settings - Fork 409
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
Fix #9653 embedded icons are correctly loaded #9660
Conversation
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.
Instead to update all project with the font-awesome links in all template I would like to propose a different approach:
- remove all the from all the html files
- create a loadFontAwesome promise that check if the font-awesome css is in the page if not add it an wait the load or error
- place the loadFontAwesome just before the rendering of markers in the drawIcons promise of StyleParserUtils.js
Promise to load the link stylesheet:
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();
}
});
};
the we could use it inside drawIcons
export const drawIcons = (geoStylerStyle, options) => {
...
return loadFontAwesome().then(() => new Promise((resolve) => {
...
I did a quick test and it seems to work but I would better to double check if we decide to give it a try. The advantage of this approach are:
- font awesome will be loaded only when we are using a vector layer
- no need to add the link to existing custom project in the html files
@allyoucanmap please review it again |
@ElenaGallo please test this fix on DEV, thanks |
@MV88 I noticed that:
1.mp4
2.mp4
3.mp4
4.mp4 |
@ElenaGallo please test it in DEV |
Description
It seems that simply adding the css to the html file fixed the issue
Please check if the PR fulfills these requirements
What kind of change does this PR introduce? (check one with "x", remove the others)
Issue
What is the current behavior?
Fix #9653
What is the new behavior?
Breaking change
Does this PR introduce a breaking change? (check one with "x", remove the other)
Other useful information