hi Alex,<br><br>You can find a way to pick up a clickevent in the map at <a href="http://openlayers.org/dev/examples/click.htm">http://openlayers.org/dev/examples/click.htm</a> :<br><br><pre id="line1">map.events.register(&quot;click&quot;, map, function(e) { 
<br>                var lonlat = map.getLonLatFromViewPortPx(e.xy);<br>                alert(&quot;You clicked near &quot; + lonlat.lat + &quot; N, &quot; +<br>                                          + lonlat.lon + &quot; E&quot;);
<br>            });</pre><br>You can change the alert part to a destroy popup code. You should know though that the code you&#39;ve written destroys a specific popup, named &#39;popup&#39;. The add function in this example could also have been:
<br><br><pre id="line1">daspop = new OpenLayers.Popup(&quot;chicken&quot;, <br>                                         new OpenLayers.LonLat(5,40),<br>                                         new OpenLayers.Size(200,200),
<br>                                         &quot;example popup&quot;,<br>                                         true);<br>        <br>            map.addPopup(daspop);<br></pre><br> <div><span class="gmail_quote">In which case the destroy code would have been:
<br><br></span><pre id="line1">markers.map.removePopup(daspop);<br>                daspop.<span id="__firefox-findbar-search-id" style="padding: 0pt; background-color: yellow; color: black; display: inline; font-size: inherit;">
destroy</span>();<br>                daspop = null;</pre><br><span class="gmail_quote">In other words, in your code you will have to find out the name of the popup that is being shown, before you can destroy it. I have no idea how you should do that. Maybe someone else could answer that (or correct me when I&#39;m wrong)?
<br><br>On 2/2/07, <b class="gmail_sendername">Alexandre Leroux</b> &lt;<a href="mailto:alexandre.leroux@ec.gc.ca">alexandre.leroux@ec.gc.ca</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi list,<br><br>I&#39;m using OpenLayers.Layer.Text to plot some markers. I&#39;d like popups to<br>disappear when a click on the map is done. Right now, the popup<br>disappear only if (1) another markers is selected and a new popup first
<br>this second marker is shown, or if (2) the marker is clicked again. This<br>is not convenient to me.<br><br>I looked at the popups.html example provided. I simply added the destroy<br>popup code.<br><br>In my map div I added:
<br>&lt;div id=&quot;map&quot; onclick=&quot;destroy()&quot;&gt;&lt;/div&gt;<br><br>and in my script section:<br>function destroy() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;popup.destroy();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>But it does not work. Any idea why? It there another way to remove
<br>popups on clicks? Should I open a ticket?<br><br>Thanks &amp; have a great Friday!<br><br>Alex :-)<br><br>--<br>Alexandre Leroux, M.Sc., Ing.<br>Environnement Canada / Environment Canada<br>Centre météorologique canadien / Canadian Meteorological Centre
<br>Division de la réponse aux urgences environnementales /<br>Environmental Emergency Response Division<br><a href="mailto:alexandre.leroux@ec.gc.ca">alexandre.leroux@ec.gc.ca</a><br><br>_______________________________________________
<br>Users mailing list<br><a href="mailto:Users@openlayers.org">Users@openlayers.org</a><br><a href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a><br></blockquote></div><br>
<br clear="all"><br>-- <br>Robert Buzink, website ontwerp en ontwikkeling<br>Sint-Pietersaalststraat 123<br>9000 Gent<br>+32 (0)9 33 00 267<br>+32 (0)487 548 414<br><a href="mailto:post@robertbuzink.nl">post@robertbuzink.nl
</a><br><a href="http://robertbuzink.nl/webdesign">robertbuzink.nl/webdesign</a>