[英]Font Awesome icon as marker in Google Maps API V3
I want to use a font awesome icon as Google Maps marker. 我想使用字体真棒图标作为Google地图标记。 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. 我想知道是否还有另一种方法可以做到这一点。
Yes, there is. 就在这里。 You can use RichMarker 您可以使用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>'
});
}
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
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.