【问题标题】:Font Awesome icon as marker in Google Maps API V3在 Google Maps API V3 中作为标记的 Font Awesome 图标
【发布时间】:2016-08-14 08:30:55
【问题描述】:

我想使用一个很棒的字体图标作为谷歌地图标记。 这是我的代码:

function addMarker(marker) {    
    marker1 = new google.maps.Marker({ 
    position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
    category: obj.status,
    map: map,
    icon: // Font Awesome icon here
});

我查看了this 问题,但不幸的是,这对我来说不能正常工作。 我想知道是否有其他方法可以做到这一点。

【问题讨论】:

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


    【解决方案1】:

    是的,有。你可以使用RichMarker

    例子:

    function addMarker(marker) {    
            marker1 = new RichMarker({ 
                position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
                category: obj.status,
                map: map,   
                draggable: false,
                flat:true,
                anchor: RichMarkerPosition.MIDDLE,
                content: '<i class="fa fa-map-marker fa-2x"></i>'
            });
    }
    

    【讨论】:

      【解决方案2】:

      另一种可能的解决方案是这样(不使用其他外部库):

      marker1 = new google.maps.Marker({
          position: new google.maps.LatLng(obj.geo_lat,obj.geo_lng),
          map: map,
          label: {
              fontFamily: 'Fontawesome',
              text: '\uf192', //code for font-awesome icon
              fontSize: '15px',
              color: 'red'
          },
          icon: {
              path: google.maps.SymbolPath.CIRCLE, //or any others
              scale: 0
          }
      });
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-28
      • 2012-06-18
      • 2011-12-19
      • 2012-01-25
      • 2012-05-11
      • 2011-09-05
      • 2016-11-06
      相关资源
      最近更新 更多