[英]Font Awesome icon as marker in Google Maps API V3
我想使用字體真棒圖標作為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
});
我看過這個問題,但不幸的是,這對我來說不合適。 我想知道是否還有另一種方法可以做到這一點。
就在這里。 您可以使用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>'
});
}
另一個可能的解決方案是這個(不使用其他外部庫):
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.