我正在设置 map 标记,我想添加很棒的字体标记。 我正在使用第 3 方 api (OverlappingMarkerSpiderfier ) 需要标记 URL。
现在我得到了一个本地标记,marker.svg。但我想使用awesome font的标记,有什么办法可以调用awesome font mark吗?
iconURL = 'marker.svg'
iconSize = new (google.maps.Size)(23, 32)
marker.setIcon
url: iconURL
scaledSize: iconSize
最佳答案
字体不能用于标记图像。
不过,nathan-m将字体转换为图像,您可以使用这些:
https://github.com/nathan-muir/fontawesome-markers
他的answer对于同一个问题有一个代码示例。
You can manually include the JS file, or use npm install fontawesome-markers or bower install fontawesome-markers.
Just include the javascript file fontawesome-markers.min.js and you can use them like so:
new google.maps.Marker({
map: map,
icon: {
path: fontawesome.markers.EXCLAMATION,
scale: 0.5,
strokeWeight: 0.2,
strokeColor: 'black',
strokeOpacity: 1,
fillColor: '#f8ae5f',
fillOpacity: 0.7
},
clickable: false,
position: new google.maps.LatLng(lat, lng)
});
关于javascript - 我可以在 URL 请求中使用很棒的字体吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43993230/