0
我爲InfoBox創建了一個自定義關閉按鈕,但無法關閉它。我試圖創建一個eventlistener,當點擊該框時,但目前還沒有運氣。代碼如下:如何定位Google地圖自定義InfoBox上的元素?
InfoPopupbox.prototype = new google.maps.OverlayView();
InfoPopupbox.prototype.onAdd = function() {
//add is after the map has been initiated
var div = document.createElement('div');
var classname = "infoWrapper ";
if (this.customclass){
classname += this.customclass;
}
div.className = classname ;
div.style.border = "none";
div.style.borderWidth = "0px";
div.style.position = "absolute";
div.appendChild(this.content_);
this.div_ = div;
var panes = this.getPanes();
//panes.overlayLayer.appendChild(div);
//float the Pane above the map
panes.floatPane.appendChild(div);
google.maps.event.addListener(this , 'click' , function(){
console.log('click close');
that.infotoggle();
});
};
這完美地工作!謝謝。 – jon