Openlayers 4设置样式清除功能
如果设置样式,则不显示要素Openlayers 4设置样式清除功能,openlayers,Openlayers,如果设置样式,则不显示要素 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.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.layer.Vector的默认ol.style
笔划需要一些形状的特征,如圆、多边形等,。简单的ol.geom.point
没有形状。这就是为什么仅使用笔划设置样式时不会显示任何内容的原因
如果您像下面这样更改样式,它将按照您的预期工作:
var style = new ol.style.Style({
image: new ol.style.Circle({ // add this
stroke: new ol.style.Stroke({
color: 'red'
}),
radius: 5
}),
});