Ok. Not really sure where to put this, when does it fire?<br><br>        function checkPopup(feature) {<br>            if (<b>feature.popup[]</b>= null){<br>            feature.popup.destroy();<br>            }<br>        }<br>
        <br>
        map.events.register(&quot;moveend&quot;, map, checkPopup);<br>I have FireBug but do not really know what to check :-(<br><br>Forgive my small knowledge here.<br><br>/asle<br><br><br><div class="gmail_quote">2009/6/8 Alexandre Dube <span dir="ltr">&lt;<a href="mailto:adube@mapgears.com">adube@mapgears.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
 &quot;this&quot; in your checkPopup function is equal to you map object and it has no popup property but has a popups array.<br>
<br>
 Do you use firebug ?  If not, you should give it a try.<br>
<br>
Alexandre<br>
<br>
Asle Benoni wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">
Hi,<br>
I did not understand this as I cannot find &quot;Moveend&quot; as a defined event. Or maybe I am missing something.<br>
I have the following function under to define the popup box. I tried to write the checkPopup function without success:<br>
<br>
            // popup box<br>
          selectControl = new OpenLayers.Control.SelectFeature(map.layers[5],{onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});<br>
           map.addControl(selectControl);<br>
           selectControl.activate();<br>
                     function onPopupClose(evt) {<br>
                selectControl.unselect(selectedFeature);<br>
            }<br>
<br>
        function onFeatureSelect(feature) {<br>
            selectedFeature = feature;<br>
            popup = new OpenLayers.Popup.FramedCloud(&quot;chicken&quot;,<br>
                                     feature.geometry.getBounds().getCenterLonLat(),<br>
                                     new OpenLayers.Size(100,200),<br>
                    &quot;&lt;h2&gt;&quot; +feature.attributes.gardsnavn +<br>
                    &quot;&lt;/h2&gt;Type: &quot;+ feature.attributes.art +<br>
                     &quot;&lt;br /&gt;Kommune: &quot;+ feature.attributes.komm +<br>
                     &quot;&lt;br /&gt;Beskrivelse&lt;br /&gt;&lt;a href=&#39;&quot; + feature.attributes.urltilpdfark +<br>
                     &quot;&#39; target=blank&gt;&lt;img src=&#39;<a href="http://naturkart.no:8080/geoserver/images/logo.png" target="_blank">http://naturkart.no:8080/geoserver/images/logo.png</a>&#39; border=&#39;0&#39; alt=&#39;naturkart&#39;&gt;&lt;/a&gt;&quot;, null, true, onPopupClose);<br>

            feature.popup = popup;<br>
            map.addPopup(popup);<br>
        }<br>
        function onFeatureUnselect(feature) {<br>
            map.removePopup(feature.popup);<br>
            feature.popup.destroy();<br>
            feature.popup = null;<br>
        }               function checkPopup(feature) {<br>
            if (feature.popup!= null){<br>
            feature.popup.destroy();<br>
            }<br>
        }<br>
               map.events.register(&quot;moveend&quot;, map, checkPopup);<br>
<br>
<br>
/asle<br>
<br></div></div>
2009/6/4 Alexandre Dube &lt;<a href="mailto:adube@mapgears.com" target="_blank">adube@mapgears.com</a> &lt;mailto:<a href="mailto:adube@mapgears.com" target="_blank">adube@mapgears.com</a>&gt;&gt;<div class="im"><br>
<br>
    Hi,<br>
<br>
    Register a &quot;moveend&quot; event to your map objet :<br>
<br>
    yourMapObj.events.register(&quot;moveend&quot;, yourMapObj, checkPopup)<br>
<br>
    Then, in your checkPopup function, check your map if it has any<br>
    popup and destroy them.<br>
<br>
    Regards,<br>
<br>
    Alexandre<br>
<br>
    Asle Benoni wrote:<br>
<br>
        Hello,<br>
        I have some popups from a WFS layer and a KML layer . When I<br>
        click the  point the popup shows. If I zoom in or out without<br>
        closing the popup  the popup stays and I cannot close it. Is<br>
        there a way to automatically  close any popups that are open<br>
        when zooming in or out?<br>
<br>
        Thanks for any help!<br>
<br>
        /asle<br>
        _______________________________________________<br>
        Users mailing list<br></div>
        <a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a> &lt;mailto:<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a>&gt;<div class="im"><br>
        <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
         <br>
<br>
<br>
    --     Alexandre Dubé<br>
    Mapgears<br></div>
    <a href="http://www.mapgears.com" target="_blank">www.mapgears.com</a> &lt;<a href="http://www.mapgears.com" target="_blank">http://www.mapgears.com</a>&gt;<br>
<br>
<br>
------------------------------------------------------------------------<div class="im"><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>
<a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
  <br>
</div></blockquote><div><div></div><div class="h5">
<br>
<br>
-- <br>
Alexandre Dubé<br>
Mapgears<br>
<a href="http://www.mapgears.com" target="_blank">www.mapgears.com</a><br>
<br>
</div></div></blockquote></div><br>