In openlayers (v4.6.4) when I'm using font-awesome as marker icons, they don't show up at first load (empty cache and hard reload). All I see is a rectangle, like a broken character. At the second load they appear perfectly.
var mapMarkerIcon = new ol.style.Style({
text: new ol.style.Text({
text: '\uf041 ', // <-- fa marker unicode
font: 'Normal ' + 24 + 'px ' + 'FontAwesome',
textBaseline: 'bottom',
fill: new ol.style.Fill({
color: green,
})
})
});
I guess this is because openlayers draws the unicode icon code before font-awesome css had the chance to load. At the second refresh, the page cached the css and that's why it works.
I can't ask all my users to refresh one time. Has someone any idea how to solve this problem?
Can I force the JS to wait for css?
I'm thinking that I only need one icon for the moment (the map-marker). Maybe I can just load this one to make it faster? (I guess even then there is no guarantee to have the css before the JS runs)
Can I add a little piece of javascript to redraw the icons after a few ms or something?