4

I want to use a font awesome icon as Google Maps marker. Here is my code:

function addMarker(marker) {    
    marker1 = new google.maps.Marker({ 
    position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
    category: obj.status,
    map: map,
    icon: // Font Awesome icon here
});

I've looked at this question, but unfortunately this is not working properly for me. I was wondering if there's another way to do this.

Community
  • 1
  • 1
mishad050
  • 448
  • 5
  • 15

2 Answers2

4

Yes, there is. You can use RichMarker

Example:

function addMarker(marker) {    
        marker1 = new RichMarker({ 
            position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
            category: obj.status,
            map: map,   
            draggable: false,
            flat:true,
            anchor: RichMarkerPosition.MIDDLE,
            content: '<i class="fa fa-map-marker fa-2x"></i>'
        });
}
dcclassics
  • 896
  • 1
  • 12
  • 38
disprog
  • 72
  • 4
3

Another possible solution is this (without use of other external libraries):

marker1 = new google.maps.Marker({
    position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
    map: map,
    label: {
        fontFamily: 'Fontawesome',
        text: '\uf192', //code for font-awesome icon
        fontSize: '15px',
        color: 'red'
    },
    icon: {
        path: google.maps.SymbolPath.CIRCLE, //or any others
        scale: 0
    }
});
David71
  • 51
  • 3
  • just adding api doc : https://developers.google.com/maps/documentation/javascript/reference#MarkerLabel – FAjir Oct 25 '17 at 08:03