mishad050 mishad050 - 1 month ago 79
Javascript Question

Font Awesome icon as marker in Google Maps API V3

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.

Answer

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>'
        });
}