[OpenLayers-Users] erase drawn features
Mike Quentel
mikequentel at yahoo.com
Fri Apr 6 17:45:26 EDT 2007
Tim, thank you.
This seems to work well:
function destroyDrawingLayer() {
for(i = 0; i < map.layers.length; i++) {
var currentLayer = map.layers[i];
if (currentLayer.isVector) {
currentLayer.destroyFeatures();
} //if (currentLayer...
} // for (i = 0...
} //function destroyDrawingLayer...
Mike Quentel
----- Original Message ----
From: Tim Schaub <noreply at geocartic.com>
To: users at openlayers.org
Sent: Friday, 6 April, 2007 10:59:56 AM
Subject: Re: [OpenLayers-Users] erase drawn features
Mike Quentel wrote:
> Please, advice on implementing functionality to erase all drawn features?
All drawn features are associated with a layer. To remove features from
a layer (which will also erase them), use:
// given a vector layer and an array of features
layer.removeFeatures(features);
To remove all features from a layer, you could use:
layer.removeFeatures(layer.features);
Note that this is currently broken - and will be until the patch for
#645 is in [1].
The layer.removeFeatures method doesn't actually destroy the features
that you send it - so you could be leaking memory if you use this
regularly. If you want to actually get rid of all the features in a
layer, use:
// erase features and get rid of the evidence
layer.destroyFeatures();
The one thing that is missing here is an eraseFeature or eraseFeatures
method. This would only temporarily erase the visual representation of
the features - leaving them as part of the layer.features array.
(Perhaps this will come with 2.5.)
Let me know if that doesn't answer your question.
Tim
[1] http://trac.openlayers.org/ticket/645
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
___________________________________________________________
What kind of emailer are you? Find out today - get a free analysis of your email personality. Take the quiz at the Yahoo! Mail Championship.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
More information about the Users
mailing list