Merge pull request #2242 from elemoine/feature-clone

Add ol.Feature#clone
This commit is contained in:
Éric Lemoine
2014-06-25 09:43:41 +02:00
2 changed files with 58 additions and 0 deletions

View File

@@ -84,6 +84,27 @@ ol.Feature = function(opt_geometryOrValues) {
goog.inherits(ol.Feature, ol.Object);
/**
* Clone this feature. If the original feature has a geometry it
* is also cloned. The feature id is not set in the clone.
* @return {ol.Feature} The clone.
* @todo api
*/
ol.Feature.prototype.clone = function() {
var clone = new ol.Feature(this.getProperties());
clone.setGeometryName(this.getGeometryName());
var geometry = this.getGeometry();
if (goog.isDefAndNotNull(geometry)) {
clone.setGeometry(geometry.clone());
}
var style = this.getStyle();
if (!goog.isNull(style)) {
clone.setStyle(style);
}
return clone;
};
/**
* @return {ol.geom.Geometry|undefined} Geometry.
* @todo api