Add clone methods to styles

This commit is contained in:
simonseyock
2016-09-01 16:19:56 +01:00
committed by Simon Seyock
parent f61a43b3c6
commit c561f1587b
7 changed files with 163 additions and 5 deletions
+20
View File
@@ -71,6 +71,26 @@ ol.style.Style = function(opt_options) {
};
/**
* Clones the style.
* @return {ol.style.Style} The cloned style.
* @api
*/
ol.style.Style.prototype.clone = function() {
var geometry = this.getGeometry();
if (geometry && geometry.clone) {
geometry = geometry.clone();
}
return new ol.style.Style({
geometry: geometry,
fill: this.getFill() ? this.getFill().clone() : undefined,
stroke: this.getStroke() ? this.getStroke().clone() : undefined,
text: this.getText() ? this.getText().clone() : undefined,
zIndex: this.getZIndex()
});
};
/**
* Get the geometry to be rendered.
* @return {string|ol.geom.Geometry|ol.StyleGeometryFunction}