admin管理员组文章数量:1307764
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.
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.
Share Improve this question edited May 23, 2017 at 12:24 CommunityBot 11 silver badge asked Apr 21, 2016 at 8:53 mishad050mishad050 4485 silver badges15 bronze badges2 Answers
Reset to default 4Yes, 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>'
});
}
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
}
});
本文标签: javascriptFont Awesome icon as marker in Google Maps API V3Stack Overflow
版权声明:本文标题:javascript - Font Awesome icon as marker in Google Maps API V3 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741850473a2401037.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论