javascript - 我可以在 URL 请求中使用很棒的字体吗?

标签 javascript google-maps google-maps-api-3 font-awesome

我正在设置 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/

相关文章:

javascript - Shopify 订单项属性 通过 Ajax 上传图像

javascript - 基于数据d3.js绑定(bind)svg渐变

android - flutter : How to launch the Google Map app with "directions" to a predefined location?

android - Pie 及以上版本的 Google map

javascript - 如何将我的谷歌地图应用程序转换为谷歌地球应用程序?

google-maps-api-3 - Google map api 的版本特定路径

google-maps-api-3 - Google Maps v3在两点之间创建路线

javascript - 如何将 opening_hours.js 包含到 node.js 脚本中?

javascript - 通过篡改 POST 负载来远程包含文件。真的可以通过 HTTPS 实现吗?

objective-c - 查找两地之间的路线数