[OpenLayers-Users] Destroying all the features in a vector layer

Simone Gadenz simone.gadenz at jrc.it
Tue Aug 5 08:29:43 EDT 2008


Thanks this helps a lot. In case, would be possible to retrieve the name of the popup, I mean the one specified in the following line:

popup = new OpenLayers.Popup("chicken",

so that something like this makes sense:

for (var i = map.popups.length - 1; i >= 0; --i) {
	if (map.popup[i].NAME == "chicken){    
		map.removePopup(map.popups[i]);
	}
}

Thnaks

S.
-----Original Message-----
From: Eric Lemoine [mailto:eric.c2c at gmail.com] 
Sent: 05 August 2008 13:30
To: Simone Gadenz
Cc: users at openlayers.org
Subject: Re: [OpenLayers-Users] Destroying all the features in a vector layer

On Tue, Aug 5, 2008 at 11:49 AM, Simone Gadenz <simone.gadenz at jrc.it> wrote:
> Hello!
>
>
>
> I have a layer of vector geocoded features that I want to be clean when the
> users click on a button.
>
> The features react to the user interaction opening a popup managed by the
> SelectFeatures control.
>
>
>
> I manage to remove all the feature from the map using a very simple function
> like this:
>
>
>
> function clearData(layer){
>
>       layer.destroyFeatures();
>
> }
>
>
>
> The problem is if one popup is open when the functio is called. In that case
> the popup is not destroyed.
>
>
>
> Is there a way of removing all the popups?

There's nothing in the API. But you can do it with this:

for (var i = map.popups.length - 1; i >= 0; --i) {
    map.removePopup(map.popups[i]);
}

--
Eric

--
Eric




More information about the Users mailing list