インフォボックス(グーグルマップ)で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に感謝します;(