Google Maps API V3中使用Font Awesome图标作为标记符号

4
我想使用Font Awesome图标作为Google地图标记。这是我的代码:
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
});

我看过这个问题,但是很遗憾对我来说并没有正常工作。 我想知道是否有其他方法可以实现这个功能。

2个回答

4

是的,有办法。您可以使用RichMarker

示例:

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

3
另一种可能的解决方案是(不使用其他外部库):
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
    }
});

{btsdaf} - FAjir

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接