[OpenLayers-Dev] popups lose focus

Andreas Hocevar ahocevar at opengeo.org
Tue Dec 14 07:14:33 EST 2010


the problem is with your application code.

First of all, your onPopupClose function should call this.hide(). And second, the reason why you see the error in firebug is because your click on the close (x) propagates to the map, which causes your currently selected feature to be unselected (due to your clickout:true option on the selectFeature control). So you will also want to stop the click on the (x) from propagating to the ma by adding OpenLayers.Event.stop(evt) to your onPopupClose function. And finally, you never set a feature on the scope of your selectControl, so this.feature will be null.

To sum this up, change your onPopupClose function to:

function(evt) {
    if (layer.selectedFeatures.length) > 0) {


On Dec 14, 2010, at 12:22 , acousmetre wrote:

> Dear dev list,
> I sent the message below (and another similar) to the openlayers users
> list but haven't received a response. Hope someone here can suggest
> something. To add one thing to the message below, firebug shows a
> "layer is null" error when popups are orphaned. I've googled for this
> problem and while i've found similar issues, haven't seen a solution
> or a good workaround. Here's the message - cheers, Iain :
> Hi list,
> I have an openlayers page about 99% done. Have one enduring problem
> which I wrote to the list about some time ago, but it didn't get
> resolved.
> The popups read content dynamically into an iframe. Popups with a large
> amounts of content sometimes lose focus and can't be closed using the
> close button on the popup. This problem has been alleviated by a resize
> operation that ensures that each popup is smaller in height than the
> viewport, but the loss of focus still happens. As a workaround I added a
> click-handler that destroys any orphaned popups when the map (and not
> the popup) is clicked (and not dragged). This works but is not exactly
> satisfactory. 
> Is there anything i can do so that the popups never lose focus? There
> will only ever be one popup open at any one time.
> My page is here: http://rabeca.org/index.htm
> The problem occurs more frequently with the three most southerly
> markers, which have bulkier content.
> Hope someone can help.
> Cheers,
> Iain 
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev

Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

More information about the Dev mailing list