Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers 4设置样式清除功能_Openlayers - Fatal编程技术网

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
  }),
});