<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi everyone,<br>
<br>
I'm new with Geoext, and I got some troubles to remove a popup when
this is unselected. The code I'm using for create the Popup is below:<br>
<br>
<font face="monospace">var report = function(e) {<br>
OpenLayers.Console.log(e.type, e.feature.id)};<br>
<br>
var highlightCtrl = new OpenLayers.Control.SelectFeature(espana,
{<br>
<br>
hover: false,<br>
highlightOnly: true,<br>
renderIntent: "temporary",<br>
eventListeners: {<br>
beforefeaturehighlighted: report,<br>
featurehighlighted: report,<br>
featureunhighlighted: report<br>
}<br>
});<br>
<br>
var selectCtrl = new
OpenLayers.Control.SelectFeature(espana,<br>
{clickout: true}<br>
);<br>
<br>
map.addControl(highlightCtrl);<br>
map.addControl(selectCtrl);<br>
<br>
highlightCtrl.activate();<br>
selectCtrl.activate();<br>
<br>
// define "createPopup" function<br>
<br>
function createPopup(feature) {<br>
popup = new GeoExt.Popup({<br>
title: 'My Popup',<br>
location: feature,<br>
width:200,<br>
html: feature.attributes.NOMBRE99,<br>
maximizable: true,<br>
collapsible: true<br>
});<br>
// unselect feature when the popup<br>
// is closed<br>
popup.on({<br>
close: function() {<br>
if(OpenLayers.Util.indexOf(espana.selectedFeatures,<br>
this.feature) > -1)
{<br>
selectCtrl.unselect(this.feature);<br>
}<br>
}<br>
}); <br>
<br>
mapPanel.remove(popup);<br>
<br>
<br>
popup.show();<br>
}<br>
<br>
<br>
<br>
// create popup on "featureselected"<br>
espana.events.on({<br>
featureselected: function(e) {<br>
createPopup(e.feature);<br>
}<br>
});</font><br>
<br>
Any idea is wellcomed. Thanks a lot per advance!!!<br>
</body>
</html>