Merge pull request #2242 from elemoine/feature-clone
Add ol.Feature#clone
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user