Reputation: 119
I need your help to add event clic into tab infobubble. This event should show an alert by clicking on the tab tab 1. The problem starts when I can not create an id on the tab
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);
}
});
}
Upvotes: 0
Views: 90
Reputation: 26
I added the id to tab 1 but the click event did not work. Please write tab 1 like this.
infoBubble.addTab('<div onclick="myfunction();">Tab1</div>', div);
//tab 1 click event
function myfunction(){
alert("Tab1");
}
Upvotes: 1