Write modifications back to the original layer

With the feature's getOriginal() and setOriginal() methods, an
undo tree can be maintained now.
This commit is contained in:
ahocevar
2013-11-09 15:14:11 +01:00
parent a3b18bf16e
commit fec638e8be
2 changed files with 34 additions and 2 deletions

View File

@@ -42,6 +42,13 @@ ol.Feature = function(opt_values) {
*/
this.geometryName_;
/**
* Original of this feature when it was modified.
* @type {ol.Feature}
* @private
*/
this.original_ = null;
/**
* The render intent for this feature.
* @type {ol.layer.VectorLayerRenderIntent|string}
@@ -101,6 +108,15 @@ ol.Feature.prototype.getGeometry = function() {
};
/**
* Get the original of this feature when it was modified.
* @return {ol.Feature} Original.
*/
ol.Feature.prototype.getOriginal = function() {
return this.original_;
};
/**
* Get any symbolizers set directly on the feature.
* @return {Array.<ol.style.Symbolizer>} Symbolizers (or null if none).
@@ -176,6 +192,15 @@ ol.Feature.prototype.setGeometry = function(geometry) {
};
/**
* Set the original of this feature when it was modified.
* @param {ol.Feature} original Original.
*/
ol.Feature.prototype.setOriginal = function(original) {
this.original_ = original;
};
/**
* Gets the renderIntent for this feature.
* @return {string} Render intent.