I am trying to create a googleMap that uses dynamic fontAwesome markers
I can't seem to be able to set 'Font Awesome 5 Free' as the font to be used, though.
I can set 'Fontawsome' which works, but is not a webfont (It's a .TTF installed in MY system)
var marker0 = createMarker({
position: new google.maps.LatLng(33.808678, -117.918921),
map: map,
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillColor: '#F00',
fillOpacity: 1,
strokeWeight: 0,
scale: 15
},
label: {
fontFamily: "FontAwesome",
fontWeight: '900',
text: eval("'\\u"+'f0ab'+"'"),
color: 'white'
}
}, "<h1>Marker 0</h1><p>This is the home marker.</p>");
});
here's the jsfiddle: https://jsfiddle.net/robsilva/hxt5jcu5/
It looks like Google Maps is not applying the font-family property to the marker label that I created. The syntax, according to Google's docs, looks correct, but for some reason all style but that is not being applied. Here are some before and after screens where we manually placed that font-family styling on the right element...
I got it to work, check your jsFiddle https://jsfiddle.net/as0srs2b/1/
HTML
JS
You were concatenating the unicode wrong in the label as well as the fontawesome library was missing.
Since I did not want to customize my normal npm files to ensure easy updates, my solution was to create another
scss
file which is imported into myapp.scss
and uses the idea of @rsilva to fix the problem:Thereby, I have a font family name without whitespaces but still can easily update my bootstrap package without changing any
I was on the same trouble , my map was showing a square icon instead of a nice FontAwesome. Firstly i've imported the .css and .js from cdnjs. I've never used Fontawesome before...
I delete everything and create a free account, and generate a "kit link" from https://fontawesome.com
As above, i got an url with a custom UID
That made the tricks for me when using a label :
Just enclose the font family in either double or single quotes.
As already cited by rsilva, this seems to be a bug in the API. Simulated in v3.31:
Workaround
The problem happened because there's a bug with the GoogleMaps API where fonts with space character in their name don't get set in the marker properties.
I fixed it by loading FA locally and renaming the font to remove all the spaces, i.e. "FontAwesome5Free'. Thanks everyone for your input.