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("moveend", 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"><<a href="mailto:adube@mapgears.com">adube@mapgears.com</a>></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>
"this" 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 "Moveend" 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("chicken",<br>
feature.geometry.getBounds().getCenterLonLat(),<br>
new OpenLayers.Size(100,200),<br>
"<h2>" +feature.attributes.gardsnavn +<br>
"</h2>Type: "+ feature.attributes.art +<br>
"<br />Kommune: "+ feature.attributes.komm +<br>
"<br />Beskrivelse<br /><a href='" + feature.attributes.urltilpdfark +<br>
"' target=blank><img src='<a href="http://naturkart.no:8080/geoserver/images/logo.png" target="_blank">http://naturkart.no:8080/geoserver/images/logo.png</a>' border='0' alt='naturkart'></a>", 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("moveend", map, checkPopup);<br>
<br>
<br>
/asle<br>
<br></div></div>
2009/6/4 Alexandre Dube <<a href="mailto:adube@mapgears.com" target="_blank">adube@mapgears.com</a> <mailto:<a href="mailto:adube@mapgears.com" target="_blank">adube@mapgears.com</a>>><div class="im"><br>
<br>
Hi,<br>
<br>
Register a "moveend" event to your map objet :<br>
<br>
yourMapObj.events.register("moveend", 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> <mailto:<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a>><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> <<a href="http://www.mapgears.com" target="_blank">http://www.mapgears.com</a>><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>