2017-09-16 2 views
0

탭 infobubble에 이벤트 clic을 추가하려면 도움이 필요합니다. 내가 탭 1로 ID를 추가탭 infobubble에서 ID를 추가하는 방법

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. 문제는 시작 표시해야합니다 작동하지 않았다. 이렇게 탭 1을 작성하십시오.

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

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