Using Icon Fonts as Markers in Google Maps V3

前端 未结 7 2010
醉梦人生
醉梦人生 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:07

    Here's my attempt at the same thing (using "markerwithlabel" utility library) before I realised Nathan did the same more elegantly above: http://jsfiddle.net/f3xchecf/

    function initialize() {
    
        var myLatLng = new google.maps.LatLng( 50, 50 ),
            myOptions = {
                zoom: 4,
                center: myLatLng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
                },
    
            map = new google.maps.Map( document.getElementById( 'map-canvas' ), myOptions ),
    
         marker = new MarkerWithLabel({
           position: myLatLng,
           draggable: true,
           raiseOnDrag: true,
           icon: ' ',
           map: map,
             labelContent: '',
           labelAnchor: new google.maps.Point(22, 50)
         });
    
        marker.setMap( map );
    }
    
    initialize();
    

提交回复
热议问题