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





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


  • So i guess all i really want is destroy... thanks! – CaptDragon Jun 23 '11 at 15:02
  • what does it mean to destroy a feature? Is there any methods in the OpenLayers API to destroy a single feature, e.g. feature.destroy(). Or is this simply a matter of throwing away the reference to the feature? – Jesper Tejlgaard Aug 24 '16 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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