Ili*_*oly 6 javascript openlayers-3
我ol.StyleFunction在图层上有一组。
function style(feature: ol.Feature, resolution: number): ol.style.Style {
return ol.style.Style({
// stuff from the feature properties
});
}
Run Code Online (Sandbox Code Playgroud)
并非所有功能都包含自己的样式信息。在这种情况下,我想退回到默认样式。
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
});
}
Run Code Online (Sandbox Code Playgroud)
有没有办法访问默认样式?
您可以设置回默认样式
import style from 'ol/style';
var fill = new ol.style.Fill({
color: 'rgba(255,255,255,0.4)'
});
var stroke = new ol.style.Stroke({
color: '#3399CC',
width: 1.25
});
var styles = [
new ol.style.Style({
image: new ol.style.Circle({
fill: fill,
stroke: stroke,
radius: 5
}),
fill: fill,
stroke: stroke
})
];
Run Code Online (Sandbox Code Playgroud)
如文档所示。
| 归档时间: |
|
| 查看次数: |
3438 次 |
| 最近记录: |