繁体   English   中英

Openlayers 4设置样式清除功能

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM