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> // Construyo el marcador.<br> feature = new OpenLayers.Feature(layer, new OpenLayers.LonLat(lng,lat));<br> marker = feature.createMarker();<br> markerlyr.addMarker(marker);<br>
<br> // Contenido del popup asociado al marcador.<br> var contenidoHTML = some html code;<br><br> // Construyo el popup asociado al marcador.<br> popup = feature.createPopup(true);<br> popup.setContentHTML(contenidoHTML);<br>
popup.setOpacity(0.8);<br> popup.setBorder("1px solid red");<br> popup.setBackgroundColor("white");<br> popup.setSize(new OpenLayers.Size(210,150));<br> 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> markerlyr.clearMarkers();<br> alert(map.popups.length);<br> for (var i=0; i<map.popups.length; i++) {<br> map.removePopup(map.popups[i]);<br> }<br> alert(map.popups.length);<br>
}<br><br><br>Does anybody know how solve it?<br><br>Thanks<br><br>Leandro<br>