[OpenLayers-Dev] Remove ALL popups
Leandro R
learonco at gmail.com
Thu Feb 21 08:24:58 EST 2008
Hello !!
using OpenLayers 2.5
Here is the question:
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.
function agregarPopup(lat,lng,name,fcodeName) {
// Construyo el marcador.
feature = new OpenLayers.Feature(layer, new OpenLayers.LonLat(lng,lat));
marker = feature.createMarker();
markerlyr.addMarker(marker);
// Contenido del popup asociado al marcador.
var contenidoHTML = some html code;
// Construyo el popup asociado al marcador.
popup = feature.createPopup(true);
popup.setContentHTML(contenidoHTML);
popup.setOpacity(0.8);
popup.setBorder("1px solid red");
popup.setBackgroundColor("white");
popup.setSize(new OpenLayers.Size(210,150));
map.addPopup(popup);
}
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.
function limpiarMapa() {
markerlyr.clearMarkers();
alert(map.popups.length);
for (var i=0; i<map.popups.length; i++) {
map.removePopup(map.popups[i]);
}
alert(map.popups.length);
}
Does anybody know how solve it?
Thanks
Leandro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20080221/8fa4d144/attachment.html
More information about the Dev
mailing list