Sort symbolizer groups by zIndex

Now rendering order can be controlled by setting the zIndex
symbolizer property.
This commit is contained in:
ahocevar
2013-10-03 09:37:08 -06:00
parent 17356bc3ee
commit 87e755e9e4
3 changed files with 42 additions and 1 deletions

View File

@@ -320,6 +320,7 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
}
}
}
featuresBySymbolizer.sort(this.sortByZIndex);
return featuresBySymbolizer;
};
@@ -454,6 +455,17 @@ ol.layer.Vector.prototype.setTemporary = function(temp) {
};
/**
* Sort function for `groupFeaturesBySymbolizerLiteral`.
* @param {Array} a 1st item for the sort comparison.
* @param {Array} b 2nd item for the sort comparison.
* @return {number} Comparison result.
*/
ol.layer.Vector.prototype.sortByZIndex = function(a, b) {
return a[1].zIndex - b[1].zIndex;
};
/**
* @param {Array.<ol.Feature>} features Features.
* @return {string} Feature info.