Using Icon Fonts as Markers in Google Maps V3

前端 未结 7 1996
醉梦人生
醉梦人生 2020-11-28 23:43

I was wondering whether it is possible to use icon font icons (e.g. Font Awesome) as markers in Google Maps V3 to replace the default marker. To show/insert them in a HTML o

7条回答
  •  时光说笑
    2020-11-29 00:30

    I just had the same problem - decided to do a quick and dirty conversion and host on github.

    https://github.com/nathan-muir/fontawesome-markers

    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)
    });
    

    Edit (April-2016): There's now packages for v4.2 -> v4.6.1

提交回复
热议问题