【发布时间】:2017-11-21 18:30:22
【问题描述】:
我在图层上设置了ol.StyleFunction。
function style(feature: ol.Feature, resolution: number): ol.style.Style {
return ol.style.Style({
// stuff from the feature properties
});
}
并非所有功能都包含自己的样式信息。 在这种情况下,我想回退到默认样式。
function style(feature: ol.Feature, resolution: number): ol.style.Style {
if (!hasOwnStyle(feature)) {
// defaultStyle is private :(
return ol.style.Style.defaultStyle();
}
return ol.style.Style({
// stuff from the feature properties
});
}
有没有办法访问默认样式?
【问题讨论】:
-
你试过
return feature.getStyle();??????如果未提供,则应分配。 -
@pavlos 真的,好主意!