diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 81e8d620d3..534f84670d 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -700,6 +700,12 @@ /** * @typedef {Object} ol.style.RuleOptions * @property {ol.expr.Expression|string|undefined} filter Filter. + * @property {number|undefined} maxResolution Optional maximum resolution. If + * a value is provided, the rule will apply at resolutions less than + * this value. + * @property {number|undefined} minResolution Optional minimum resolution. If + * a value is provided, the rule will apply at resolutions greater than or + * equal to this value. * @property {Array.|undefined} symbolizers Symbolizers. */ diff --git a/src/ol/style/rule.js b/src/ol/style/rule.js index 97ecb5b84c..a52c739ab0 100644 --- a/src/ol/style/rule.js +++ b/src/ol/style/rule.js @@ -39,6 +39,20 @@ ol.style.Rule = function(options) { this.symbolizers_ = goog.isDef(options.symbolizers) ? options.symbolizers : []; + /** + * @type {number} + * @private + */ + this.minResolution_ = goog.isDef(options.minResolution) ? + options.minResolution : 0; + + /** + * @type {number} + * @private + */ + this.maxResolution_ = goog.isDef(options.maxResolution) ? + options.maxResolution : Infinity; + }; diff --git a/test/spec/ol/style/rule.test.js b/test/spec/ol/style/rule.test.js index c2a2e2d821..8da0532774 100644 --- a/test/spec/ol/style/rule.test.js +++ b/test/spec/ol/style/rule.test.js @@ -2,6 +2,31 @@ goog.provide('ol.test.style.Rule'); describe('ol.style.Rule', function() { + describe('constructor', function() { + + it('accepts a filter option', function() { + var rule = new ol.style.Rule({ + filter: 'foo == "bar"' + }); + expect(rule).to.be.a(ol.style.Rule); + }); + + it('accepts a minResolution option', function() { + var rule = new ol.style.Rule({ + minResolution: 10 + }); + expect(rule).to.be.a(ol.style.Rule); + }); + + it('accepts a maxResolution option', function() { + var rule = new ol.style.Rule({ + maxResolution: 100 + }); + expect(rule).to.be.a(ol.style.Rule); + }); + + }); + describe('#applies()', function() { var feature = new ol.Feature(), rule;