Hello !!<br>using OpenLayers 2.5<br>Here is the question:<br>There is a function that, when the client click on a link, creates a marker and asociate a popup to it. There are plenty of links so plenty of markers and its popups.<br>
<br>function agregarPopup(lat,lng,name,fcodeName) {<br>&nbsp;&nbsp;&nbsp; // Construyo el marcador.<br>&nbsp;&nbsp;&nbsp; feature = new OpenLayers.Feature(layer, new OpenLayers.LonLat(lng,lat));<br>&nbsp;&nbsp;&nbsp; marker = feature.createMarker();<br>&nbsp;&nbsp;&nbsp; markerlyr.addMarker(marker);<br>
&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; // Contenido del popup asociado al marcador.<br>&nbsp;&nbsp;&nbsp; var contenidoHTML = some html code;<br><br>&nbsp;&nbsp;&nbsp; // Construyo el popup asociado al marcador.<br>&nbsp;&nbsp;&nbsp; popup = feature.createPopup(true);<br>&nbsp;&nbsp;&nbsp; popup.setContentHTML(contenidoHTML);<br>
&nbsp;&nbsp;&nbsp; popup.setOpacity(0.8);<br>&nbsp;&nbsp;&nbsp; popup.setBorder(&quot;1px solid red&quot;);<br>&nbsp;&nbsp;&nbsp; popup.setBackgroundColor(&quot;white&quot;);<br>&nbsp;&nbsp;&nbsp; popup.setSize(new OpenLayers.Size(210,150));<br>&nbsp;&nbsp;&nbsp; map.addPopup(popup);<br>}<br><br>
<br>The problem comes here: there is another function that removes all the markers and popups. The markers are correctly removed but the popups not. There is always one that is not removed. I have to run the function twice.<br>
<br>function limpiarMapa() {<br>&nbsp;&nbsp;&nbsp; markerlyr.clearMarkers();<br>&nbsp;&nbsp;&nbsp; alert(map.popups.length);<br>&nbsp;&nbsp;&nbsp; for (var i=0; i&lt;map.popups.length; i++) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; map.removePopup(map.popups[i]);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; alert(map.popups.length);<br>
}<br><br><br>Does anybody know how solve it?<br><br>Thanks<br><br>Leandro<br>