[英]Openlayers 4 set style clear feature
如果設置了樣式,則功能不顯示
new ol.layer.Vector({
source: vectorSource1,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'red'
})
})
})
如果樣式清晰
new ol.layer.Vector({
source: vectorSource1
})
全部顯示正常
var featurething = new ol.Feature({
});
featurething.setGeometry(new ol.geom.Point( ol.proj.fromLonLat([29, 29]) ));
//console.log(value);
vectorSource1.addFeature( featurething );
請參見ol.style
的默認ol.layer.Vector
http://openlayers.org/en/latest/apidoc/ol.style.html
筆觸需要某種形狀的特征,例如圓形,多邊形等。 簡單的ol.geom.point
沒有形狀。 這就是為什么當您僅通過stroke
設置樣式時什么也沒有出現的原因
如果您按照以下方式更改樣式,則它將按預期工作:
var style = new ol.style.Style({
image: new ol.style.Circle({ // add this
stroke: new ol.style.Stroke({
color: 'red'
}),
radius: 5
}),
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.