propertyStyles of a Style's default symbolizer will not be parsed unless rules are specified. r=tschaub (closes #1432)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6505 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -115,7 +115,8 @@ OpenLayers.Style = OpenLayers.Class({
|
||||
* {Object} symbolizer hash
|
||||
*/
|
||||
createSymbolizer: function(feature) {
|
||||
var style = OpenLayers.Util.extend({}, this.defaultStyle);
|
||||
var style = this.createLiterals(
|
||||
OpenLayers.Util.extend({}, this.defaultStyle), feature);
|
||||
|
||||
var rules = this.rules;
|
||||
|
||||
@@ -173,11 +174,9 @@ OpenLayers.Style = OpenLayers.Class({
|
||||
|
||||
var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;
|
||||
|
||||
var context = this.context || feature.attributes || feature.data;
|
||||
|
||||
// merge the style with the current style
|
||||
return this.createLiterals(
|
||||
OpenLayers.Util.extend(style, symbolizer), context);
|
||||
OpenLayers.Util.extend(style, symbolizer), feature);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -188,14 +187,14 @@ OpenLayers.Style = OpenLayers.Class({
|
||||
* Parameters:
|
||||
* style - {Object} style to create literals for. Will be modified
|
||||
* inline.
|
||||
* context - {Object} context to take property values from. Defaults to
|
||||
* feature.attributes (or feature.data, if attributes are not
|
||||
* available)
|
||||
* feature - {Object}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} the modified style
|
||||
*/
|
||||
createLiterals: function(style, context) {
|
||||
createLiterals: function(style, feature) {
|
||||
var context = this.context || feature.attributes || feature.data;
|
||||
|
||||
for (var i in this.propertyStyles) {
|
||||
style[i] = OpenLayers.Style.createLiteral(style[i], context);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
symbolizer: {"Point": {fillColor: "red"}},
|
||||
minScaleDenominator: 1000000,
|
||||
maxScaleDenominator: 2500000});
|
||||
style.addRules([rule1, rule2, rule3]);
|
||||
|
||||
var feature = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(3,5),
|
||||
@@ -58,9 +57,13 @@
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(3,5), 10);
|
||||
|
||||
// at this scale, the feature should be green
|
||||
var createdStyle = style.createSymbolizer(feature);
|
||||
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style correctly.");
|
||||
t.eq(createdStyle.externalGraphic, "barbar.png", "Calculated property style for default symbolizer correctly.");
|
||||
|
||||
style.addRules([rule1, rule2, rule3]);
|
||||
createdStyle = style.createSymbolizer(feature);
|
||||
|
||||
// at this scale, the feature should be green
|
||||
t.eq(createdStyle.display, "", "Feature is visible at scale "+map.getScale());
|
||||
t.eq(createdStyle.fillColor, "green", "Point symbolizer from rule applied correctly.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user