I added a panel to a map that is contained inside an IFrame. Then I attach a click handler to the div of this panel with JQuery to toggle a control.
However, I notice that a click on the panel also trigger a map click event when it should not because another control handle the map click and both the panel and the map controls are triggered together.
var olmap = iframe.contentWindow.map // openlayers map inside the iframe
var i = olmap.getControlsByClass("Korem.Control.Info")[0] //map click control
var layerControl = olmap.getControlsByClass("Korem.Control.LightLayerControl")[0]
var customPanel = new iframe.contentWindow.OpenLayers.Control.Panel({
id: "customPanel",
autoActivate: true
});
olmap.addControl(customPanel)
iframeBody = $(iframe).contents().find("body");
var panel= iframeBody.find("#customPanel")
panel.css({"position":"absolute", "top":"0", "right":"0", "width":"auto", "height":"auto", "z-index":"1033"})
panel.append('<div id="clickLink" class="MenuItem1ItemInactive" style="cursor:pointer; padding:2px 5px; border:1px solid white; font-size: 12px; font-family: Arial;">Afficher les écoles</div>');
$(iframe).contents().find("#clickLink").click(function(){
i.deactivate()
if (layerControl.active == true) {
layerControl.deactivate();
} else {
layerControl.activate();
}
});
layerControl.events.on({deactivate : function(){
i.activate();
}
});
Is it normal that a click on a panel trigger a map click also? How could I prevent it?