2017-09-16 53 views
0

我需要您的帮助才能将标签信息添加到标签信息中。这个事件应该显示通过单击选项卡标签上的警告1.问题开始时我不能在标签如何在标签信息中添加标识

http://jsfiddle.net/hT8Kw/11/

map_initialize(); // load map 
function map_initialize(){ 
    var mapOptions = { 
     center: new google.maps.LatLng(37.286172, -121.80929), 
     zoom: 8, 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }; 
    var map = new google.maps.Map(document.getElementById("map_canvas"), 
     mapOptions); 

    var myLatlng = new google.maps.LatLng(37.286172, -121.80929); 
    var marker = new google.maps.Marker({ 
     position: myLatlng, 
     map: map, 
     title: 'A Customized InfoWindow Marker' 
    }); 

    var infoBubble = new InfoBubble({ 
     maxWidth: 300 
    }); 

    var div = document.createElement('DIV'); 
    div.innerHTML = 'Hello'; 

    infoBubble.addTab('Tab 1', div); 
    infoBubble.addTab('Tab 2', "1234"); 

    //Add event clic into Tab 1. If click in Tab 1 show alert. 

    google.maps.event.addListener(marker, 'click', function() { 
     if (!infoBubble.isOpen()) { 
     infoBubble.open(map, marker); 
     } 
    }); 
    } 

回答

1

我加入了ID到标签1,但click事件上创建一个id不工作。 请这样写标签1。

infoBubble.addTab('<div onclick="myfunction();">Tab1</div>', div); 

//tab 1 click event 
function myfunction(){ 
 alert("Tab1"); 
}