[New] raise feature function to move features in layer.

This commit is contained in:
Slawomir Messner
2012-09-18 08:14:54 +02:00
parent 503fff32b6
commit cb1c3a834a
2 changed files with 77 additions and 2 deletions

View File

@@ -699,7 +699,28 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
this.events.triggerEvent("featuresremoved", {features: features});
}
},
/**
* APIMethod: raiseFeature
* Changes the index of the given feature by delta and redraws the layer. If delta is positive, the feature is moved up the layer's feature stack; if delta is negative, the feature is moved down.
* If delta + current is negative it is set to 0 and feature will be at the bottom; if it is bigger then the features count than it is set to the last index and the feature will be at the top.
*/
raiseFeature:function(feature, delta) {
var base = this.features.indexOf(feature);
var idx = base + delta;
if (idx < 0) {
idx = 0;
} else if (idx > this.features.length) {
idx = this.features.length;
}
if (base != idx) {
this.features.splice(base, 1);
this.features.splice(idx, 0, feature);
this.eraseFeatures(this.features);
this.redraw();
}
},
/**
* APIMethod: removeAllFeatures
* Remove all features from the layer.