Consider resolution when applying rules
This commit is contained in:
@@ -58,11 +58,16 @@ ol.style.Rule = function(options) {
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {number} resolution Map resolution.
|
||||
* @return {boolean} Does the rule apply to the feature?
|
||||
*/
|
||||
ol.style.Rule.prototype.applies = function(feature) {
|
||||
return goog.isNull(this.filter_) ?
|
||||
true : !!ol.expr.evaluateFeature(this.filter_, feature);
|
||||
ol.style.Rule.prototype.applies = function(feature, resolution) {
|
||||
var applies = resolution >= this.minResolution_ &&
|
||||
resolution < this.maxResolution_;
|
||||
if (applies && !goog.isNull(this.filter_)) {
|
||||
applies = !!ol.expr.evaluateFeature(this.filter_, feature);
|
||||
}
|
||||
return applies;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -45,17 +45,18 @@ ol.style.Style = function(options) {
|
||||
/**
|
||||
* Create an array of symbolizer literals for a feature.
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {number} resolution Map resolution.
|
||||
* @return {Array.<ol.style.Literal>} Symbolizer literals for the
|
||||
* feature.
|
||||
*/
|
||||
ol.style.Style.prototype.createLiterals = function(feature) {
|
||||
ol.style.Style.prototype.createLiterals = function(feature, resolution) {
|
||||
var rules = this.rules_,
|
||||
symbolizers = [],
|
||||
applies = false,
|
||||
rule;
|
||||
for (var i = 0, ii = rules.length; i < ii; ++i) {
|
||||
rule = rules[i];
|
||||
if (rule.applies(feature)) {
|
||||
if (rule.applies(feature, resolution)) {
|
||||
applies = true;
|
||||
symbolizers.push.apply(symbolizers, rule.getSymbolizers());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user