Sort symbolizer groups by zIndex
Now rendering order can be controlled by setting the zIndex symbolizer property.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user