Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm doing the following in my code and am wondering if it's too much or is there any benefit?

        myLayer.removeAllFeatures();
        myLayer.destroyFeatures();

Reference:

http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Layer/Vector-js.html#OpenLayers.Layer.Vector.removeAllFeatures

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

Copy and paste from the OpenLayers mailing list:

Hi Ian. removeFeatures removes the feature from the layer (and from the feature array) but the features aren't destroyed, for example they can later be added back to the layer. After removeFeatures the layer has no references on the layers, user code is therefore responsible for destroying the features and releasing references so that the features are garbage-collected. After destroyFeatures the features are removed from the layer and destroyed. Like after removeFeatures they shouldn't reappear on the layer after redraw, if you observe otherwise it's certainly a bug that we need to track down. Cheers. Eric

http://www.mail-archive.com/users@openlayers.org/msg04868.html

share|improve this answer
    
So i guess all i really want is destroy... thanks! –  CaptDragon Jun 23 '11 at 15:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.