diff --git a/lib/OpenLayers/Style.js b/lib/OpenLayers/Style.js index 8ce9949d16..d7bcaf214f 100644 --- a/lib/OpenLayers/Style.js +++ b/lib/OpenLayers/Style.js @@ -85,21 +85,29 @@ OpenLayers.Style = OpenLayers.Class({ * used as default style for this style object. This style * applies if no rules are specified. Symbolizers defined in * rules will extend this default style. - * options - {Object} An optional object with properties to set on the - * userStyle + * options - {Object} An optional object with properties to set on the + * style. + * + * Valid options: + * rules - {Array()} List of rules to be added to the + * style. * * Return: * {} */ initialize: function(style, options) { + + OpenLayers.Util.extend(this, options); this.rules = []; + if(options && options.rules) { + this.addRules(options.rules); + } // use the default style from OpenLayers.Feature.Vector if no style // was given in the constructor - this.setDefaultStyle(style || - OpenLayers.Feature.Vector.style["default"]); - - OpenLayers.Util.extend(this, options); + this.setDefaultStyle(style || + OpenLayers.Feature.Vector.style["default"]); + }, /** diff --git a/tests/Style.html b/tests/Style.html index cce714e1c1..9423b78a9b 100644 --- a/tests/Style.html +++ b/tests/Style.html @@ -4,13 +4,36 @@