Patch to empty selectedFeatures when destroying all features from #665,

tschaub. This includes tests (hooray) and fixes issues with zooming a wfs
layer while you have a feature selected.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@3067 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-04-12 10:51:39 +00:00
parent 4ec005c06c
commit 1548a6c470
2 changed files with 6 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ OpenLayers.Layer.Vector.prototype =
features: null,
/** @type Array(OpenLayers.Feature.Vector) */
selectedFeatures: [],
selectedFeatures: null,
/** @type {Boolean} */
reportError: true,
@@ -252,8 +252,10 @@ OpenLayers.Layer.Vector.prototype =
},
/**
* Destroy all features on the layer and empty the selected features array.
*/
destroyFeatures: function () {
this.selectedFeatures = new Array();
for (var i = this.features.length - 1; i >= 0; i--) {
this.features[i].destroy();
}

View File

@@ -122,7 +122,7 @@
}
function test_Layer_Vector_destroyFeatures (t) {
t.plan(2);
t.plan(3);
layer = new OpenLayers.Layer.Vector(name);
var map = new OpenLayers.Map('map');
map.addLayer(layer);
@@ -133,8 +133,10 @@
}
layer.addFeatures(features);
t.eq(layer.features.length, 5, "addFeatures adds 5 features");
layer.selectedFeatures.push(features[0]);
layer.destroyFeatures();
t.eq(layer.features.length, 0, "destroyFeatures triggers removal");
t.eq(layer.selectedFeatures, [], "Destroy features removes selected features");
}
function test_99_Layer_Vector_destroy (t) {