在drawingManager'overlaycomplete'上添加信息窗口

时间:2012-09-04 18:07:59

标签: drawing maps

所以我一直想着如何在overlaycomplete事件期间向标记添加信息窗口。我已经想出如何为标记添加标题,但我无法获得一个信息窗口......请问有什么帮助吗?

以下是我目前创建标题的代码......

google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
  if (event.type == google.maps.drawing.OverlayType.MARKER) {
     event.overlay.setTitle("Hello");
  }
});

1 个答案:

答案 0 :(得分:1)

google.maps.event.addListener(drawingManager, 'overlaycomplete', function(event) {
  if (event.type == google.maps.drawing.OverlayType.MARKER) {
    //event.overlay.setTitle("Hello");
    var infowindow = new google.maps.InfoWindow({
      content: '<div id="content" onmouseover="updateContent()">Hello</div>',
      maxWidth: 10
    });
    google.maps.event.addListener(event.overlay,'click',function(){
      infowindow.open(map,event.overlay);
    });
  }
});