如何使用markerwithlabel

时间:2017-07-14 17:58:32

标签: google-maps google-maps-api-3 google-maps-markers

我正在使用带有markerwithlabel的谷歌地图,我只想显示带有标签的标签,不需要显示默认图标标记

我的消息来源:

var markerMap = new MarkerWithLabel({
      position: latLng,
      draggable: true,
      raiseOnDrag: true,
      map: map, 
      labelContent: "<div class='arrow'>1.300.000 VND</div>",
      labelAnchor: new google.maps.Point(30, 30),
      labelClass: "labels", // the CSS class for the label
      isClicked: false
});

结果:

enter image description here

然而它显示双图标(包括:defeaul图标和markerwithlabel)

我尝试了很多方法,但我找不到最好的方法。如何隐藏或禁用默认图标谷歌地图,只显示markerwithlabel?

非常感谢!

2 个答案:

答案 0 :(得分:0)

您需要设置图标的网址以隐藏默认标记图标。

var markerMap = new MarkerWithLabel({
      position: latLng,
      draggable: true,
      raiseOnDrag: true,
      map: map, 
      icon: {
         url: '' // set url as ''
      }
      labelContent: "<div class='arrow'>1.300.000 VND</div>",
      labelAnchor: new google.maps.Point(30, 30),
      labelClass: "labels", // the CSS class for the label
      isClicked: false
});

答案 1 :(得分:0)

icon: " ", // 空字符串将隐藏图标

              current_marker = new google.maps.Marker({
                                                        position: {lat: current_lat, lng: current_long},
                                                        map,
                                                        title: 'currentLocationMarker',
                                                        
                                                        icon: " ",  // an empty string will hide the icon
                                                        draggable: true
                                                    });