Displaying feature info in a popup

I'd suggest checking this openlayers example: getfeatureinfo-control. It shows the feature info in a table on the page. Putting it into a popup should be easy changing some lines in the javascript.

In general openlayers.org/dev/examples/ is a good resource for openlayers code snippets.


Is it possible that you are calling your popup creation function in the closeBoxCallback parameter? This is a snippet from some code I was working on:

      popup = new OpenLayers.Popup.FramedCloud(
             "popup",
             map.getLonLatFromViewPortPx(evt.xy),
             new OpenLayers.Size(300,150),
             "Updating<br/>information...",
             null,
             true,
             null
           );

The last null is in the place where you would put a callback function when the closeBox on the popup is clicked. In what I've displayed above, this is set to null and therefore, nothing is called and the popup doesn't reappear.

I saw in the "Open Popup on Layer.Vector" example in the OL Examples that there's a callback function here "onPopupClose". That unselects the feature which also I believe calls the onFeatureUnselect, which in turn destroys the popup. That is all setup in this line of that example:

selectControl = new OpenLayers.Control.SelectFeature(polygonLayer, {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});

So, it sounds like you need to either take out the closeBoxCallback in your popup creation (i.e. set it to null) or do something similar to this example that destroys the popup a bit later in the process.