From 1ed15843204f5d3ba46bf9f85e6d7733b67d5715 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 9 Mar 2009 22:26:05 +0000 Subject: [PATCH] Style constructor accepts a rules array. These rules will be added to the style. r=ahocevar (closes #1964) git-svn-id: http://svn.openlayers.org/trunk/openlayers@8975 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Style.js | 20 ++++++++++++++------ tests/Style.html | 31 +++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) 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 @@