mishad050
mishad050

Reputation: 448

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.

Upvotes: 4

Views: 8135

Answers (2)

David71
David71

Reputation: 51

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

Upvotes: 3

disprog
disprog

Reputation: 72

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

Upvotes: 4

Related Questions