diff --git a/lib/OpenLayers/Style.js b/lib/OpenLayers/Style.js index c04c2e717b..4bfcaef160 100644 --- a/lib/OpenLayers/Style.js +++ b/lib/OpenLayers/Style.js @@ -15,6 +15,12 @@ */ OpenLayers.Style = OpenLayers.Class({ + /** + * Property: id + * {String} A unique id for this session. + */ + id: null, + /** * APIProperty: name * {String} @@ -119,6 +125,7 @@ OpenLayers.Style = OpenLayers.Class({ this.setDefaultStyle(style || OpenLayers.Feature.Vector.style["default"]); + this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); }, /** @@ -369,6 +376,29 @@ OpenLayers.Style = OpenLayers.Class({ } }, + /** + * APIMethod: clone + * Clones this style. + * + * Returns: + * {} Clone of this style. + */ + clone: function() { + var options = OpenLayers.Util.extend({}, this); + // clone rules + if(this.rules) { + options.rules = []; + for(var i=0, len=this.rules.length; i