Add min/maxResolution properties to rule options
This commit is contained in:
@@ -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.<ol.style.Symbolizer>|undefined} symbolizers Symbolizers.
|
||||
*/
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user