<div dir="ltr">Hello,<br><br>I am drawing &quot;highlight&quot; circles in a vector layer as users select/deselect features from another layer. After reading the docs and list I got the impression that removeFeatures would remove a feature from the map but that it would continue to exist in the features array and could lead to memory leaks if overused. destroyFeatures on the other hand sounded like it would permanently remove the feature from the map and array.<br>
<br>However I&#39;m getting the opposite behavior. removeFeatures deletes the feature and it is gone from the features array (redrawing the layer also confirms this). destroyFeatures removes the feature from the map, but the feature remains in the features array and redrawing the layer redraws the deleted feature as well. Am I missing something?<br>
<br>Code snippets:<br><br>selFeatures = new OpenLayers.Layer.Vector(&quot;Selected Features&quot;, {style:&quot;&quot;});<br><br>function updateSavedFeatures (name) {<br>&nbsp; ...<br>&nbsp; // Add highlight<br>&nbsp; highlight = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(saved[name].lon, saved[name].lat));<br>
&nbsp; highlight.fid = name;<br>&nbsp; selFeatures.addFeatures(highlight);<br>&nbsp; ...<br>&nbsp; // Remove highlight<br>&nbsp; for (var key in selFeatures.features) {<br>&nbsp;&nbsp;&nbsp; if (selFeatures.features[key].fid == name) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selFeatures.removeFeatures(selFeatures.features[key]);&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //selFeatures.destroyFeatures(selFeatures.features[key]); <br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>}<br></div>