OpenLayers.Popup closeBoxCallback not fired
Hi,
i have an OpenLayers Map with some markers. Every marker has it's own popup to display when clicked on it and every Popup has a closeBoxCallback which should be fired if the popup will be hidden. It works if i click the close button of the popup but the event / callback isn't fired if i add the popup as exclusive (map.addPopup(popup, true)) and click another marker or if i hide the popup manually with popup.hide().
I want to excuse for my bad english, it's not my native language.
Does someone have the same problem or can reproduce it? Do you need more information?
I think I might be hitting the same issue than you ...
I cannot reproduce after upgrading from 2.11 to 2.12.
Hi. Until a better solution exists, I think we can use the following one:
Override the addCloseBox method from OpenLayers.Popup. Check out the changes I made.
/**
* Method: addCloseBox
*
* Parameters:
* callback - {Function} The callback to be called when the close button
* is clicked.
*/
OpenLayers.Popup.prototype.addCloseBox = function(callback) {
this.closeDiv = OpenLayers.Util.createDiv(
this.id + "_close", null, {w: 17, h: 17}
);
this.closeDiv.className = "olPopupCloseBox";
// use the content div's css padding to determine if we should
// padd the close div
var contentDivPadding = this.getContentDivPadding();
this.closeDiv.style.right = contentDivPadding.right + "px";
this.closeDiv.style.top = contentDivPadding.top + "px";
this.groupDiv.appendChild(this.closeDiv);
// COMMENT OUT THIS DEFINITION OF 'closePopup'
//var closePopup = callback || function(e) {
// this.hide();
// OpenLayers.Event.stop(e);
//};
// NEW DEFINITION OF 'closePopup'
var closePopup = function(e) {
this.hide();
/* Checks whether the callback is a function */
if (typeof callback == 'function') {
/* Triggers the callback */
callback();
}
OpenLayers.Event.stop(e);
};
OpenLayers.Event.observe(this.closeDiv, "touchend",
OpenLayers.Function.bindAsEventListener(closePopup, this));
OpenLayers.Event.observe(this.closeDiv, "click",
OpenLayers.Function.bindAsEventListener(closePopup, this));
};
:)