可以在Mapbox Markers中使用Font Awesome图标吗?

bdk*_*172 2 icons marker mapbox

我正在使用Maki图标集,但它们非常有限,并且希望能够使用Font Awesome图标.这可能吗?

这是我用来设置标记图标的代码.

marker.setIcon(L.mapbox.marker.icon({
    'title': jobid,
    'marker-color': '#e32f2f',
    'marker-symbol': 'square'
}));
Run Code Online (Sandbox Code Playgroud)

小智 6

如果您在页面上包含字体很棒的CSS,则可以使用L.DivIcon构造函数来创建自定义图标.

<style>
/*
 * Unlike other icons, you can style `L.divIcon` instances with CSS.
 * These styles make each marker a circle with a border and centered
 * text
 */
.fa-icon {color: red;}
</style>
<div id='map'></div>
<script>
var map = L.mapbox.map('map', 'examples.map-i86nkdio')
    .setView([45.52245801087795, -122.67773866653444], 3);

L.marker([45.52245801087795, -122.67773866653444], {
    icon: L.divIcon({
        // specify a class name that we can refer to in styles, as we
        // do above.
        className: 'fa-icon',
        // html here defines what goes in the div created for each marker
        html: '<i class="fa fa-camera-retro fa-3x"></i>',
        // and the marker width and height
        iconSize: [40, 40]
    })
}).addTo(map);
Run Code Online (Sandbox Code Playgroud)

这是一个完整的例子:http://jsbin.com/tiyote/1/