我厌倦了搜索如何在信息框(谷歌地图)中应用closeclick事件。我尝试了几乎所有我能想到但没有成功的场景。请帮我
这是我添加标记的代码:-
var ib_click = new InfoBox();
ib_click.isOpen = false;
var toShowHover = true;
function add_marker(lat,lng,icn,title,box_html) {
var mapcode,myOptions;
var marker = new google.maps.Marker({
/*marker settings*/
});
myOptions = {
/*option of infobox*/
};
marker.ibOptions = myOptions;
google.maps.event.addListener(marker, 'click', function() {
mapcode = /* html for showing box */
myOptions.content = mapcode;
myOptions.boxStyle.width = "235px";
ib_click.setOptions(marker.ibOptions);
ib_click.open(map, marker);
ib_click.isOpen = true;
toShowHover = false;
});
google.maps.event.addListener(marker, 'mouseover', function() {
//this is fired
var mapcode = /*html for showing hover*/;
//ib_click.open(map, marker);
myOptions.content = mapcode;
myOptions.boxStyle.width = "205px";
ib_click.setOptions(marker.ibOptions);
ib_click.open(map, marker);
// ib_click.isOpen = true;
});
google.maps.event.addListener(marker, 'mouseout', function() {
//alert('mouse out');//this is fired
//toShowHover = true;
});
google.maps.event.addListener(ib_click, 'closeclick', function(){
//how to use closeclick
//showing error here
alert('closed');
});
return marker;
}
请解释一下,谢谢 Ankur ;(