我有一个具有许多特征的矢量图层(3000个多边形,LineStrings和点),应该根据它们的图层索引进行渲染。出于性能原因,我必须使用单层,否则我必须将数据拆分为大约50层。
我的期望是样式定义中的zIndex应该更改渲染顺序。但这并没有改变任何事情。下面的示例已经过简化,仅显示通过应用较低的渲染顺序将“背景”类型放入后面
var zIndexValue = 1000;
function vectorStyleFunction(feature, resolution) {
if (feature.get("name:de") === "Background")
zIndexValue = 10;
//some default style
var style = new ol.style.Style({
fill: new ol.style.Fill({
color: '#00d334',
graphicZIndex: zIndexValue,
zIndex: zIndexValue
}),
stroke: new ol.style.Stroke({
color: '#d32a80',
width: 1,
graphicZIndex: zIndexValue,
zIndex: zIndexValue
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
}),
graphicZIndex: zIndexValue,
zIndex: zIndexValue
})
});
...
return style;
}
我应该怎么做才能在每个功能的基础上更改渲染顺序?
作为旁注:创建时功能的顺序正确。因此,如果有一种方法可以在创建时按顺序渲染要素,那也没关系。