[OpenLayers-Users] [OL2.8]onPopupClose multiple layers
Joel Tremblet
joel.tremblet at openflyers.com
Sat Aug 1 09:06:44 EDT 2009
Hi
Function to close a popup by clicking on closeBox seem to not working
on multiple layers
[CODE]
var selectControl = new OpenLayers.Control.SelectFeature([layer1, layer2]);
layer.events.on({
"featureselected" : onFeatureSelect,
"featureunselected" : onFeatureUnselect
});
map.addControl(selectControl);
selectControl.activate();
function onPopupClose(evt) {
selectControl.unselect(selectedFeature);
}
function onFeatureSelect(event) {
var feature = event.feature;
var selectedFeature = feature;
var popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
"<h2>"+feature.attributes.name + "</h2>" +
feature.attributes.description,
null, true, onPopupClose
);
feature.popup = popup;
map.addPopup(popup);
}
function onFeatureUnselect(event) {
var feature = event.feature;
if(feature.popup) {
map.removePopup(feature.popup);
feature.popup.destroy();
delete feature.popup;
}
[/CODE]
Ticket 2197 opened http://trac.openlayers.org/ticket/2197
Is it confirmed?
--
Joël
-|-
----O----
| |
More information about the Users
mailing list