Changed StyleMap constructor so that all render intents will be set if only one Style object or symbolizer hash is passed. This is the first patch attached to #1498, which got slightly more votes thaan the second one. r=crschmidt,tschaub (pullup #1498)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@6827 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2008-04-09 09:12:09 +00:00
parent 830b640d4a
commit ada641d866

View File

@@ -22,8 +22,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
/** /**
* Property: extendDefault * Property: extendDefault
* {Boolean} if true, every render intent will extend the symbolizers * {Boolean} if true, every render intent will extend the symbolizers
* specified for the "default" intent. Otherwise, every rendering intent * specified for the "default" intent at rendering time. Otherwise, every
* is treated as a completely independent symbolizer. * rendering intent will be treated as a completely independent style.
*/ */
extendDefault: true, extendDefault: true,
@@ -33,7 +33,9 @@ OpenLayers.StyleMap = OpenLayers.Class({
* Parameters: * Parameters:
* style - {Object} Optional. Either a style hash, or a style object, or * style - {Object} Optional. Either a style hash, or a style object, or
* a hash of style objects (style hashes) keyed by rendering * a hash of style objects (style hashes) keyed by rendering
* intent * intent. If just one style hash or style object is passed,
* this will be used for all known render intents (default,
* select, temporary)
* options - {Object} optional hash of additional options for this * options - {Object} optional hash of additional options for this
* instance * instance
*/ */
@@ -52,6 +54,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
if(style instanceof OpenLayers.Style) { if(style instanceof OpenLayers.Style) {
// user passed a style object // user passed a style object
this.styles["default"] = style; this.styles["default"] = style;
this.styles["select"] = style;
this.styles["temporary"] = style;
} else if(typeof style == "object") { } else if(typeof style == "object") {
for(var key in style) { for(var key in style) {
if(style[key] instanceof OpenLayers.Style) { if(style[key] instanceof OpenLayers.Style) {
@@ -63,6 +67,8 @@ OpenLayers.StyleMap = OpenLayers.Class({
} else { } else {
// user passed a style hash (i.e. symbolizer) // user passed a style hash (i.e. symbolizer)
this.styles["default"] = new OpenLayers.Style(style); this.styles["default"] = new OpenLayers.Style(style);
this.styles["select"] = new OpenLayers.Style(style);
this.styles["temporary"] = new OpenLayers.Style(style);
break; break;
} }
} }