2017-07-13 55 views
0

如果设置样式,功能不显示的OpenLayers 4套风格明确特征

new ol.layer.Vector({ 
source: vectorSource1, 
style: new ol.style.Style({ 
    stroke: new ol.style.Stroke({ 
      color: 'red' 
     }) 
    }) 
}) 

如果明确造型

new ol.layer.Vector({ 
source: vectorSource1 
}) 

所有显示OK

var featurething = new ol.Feature({ 
     }); 
     featurething.setGeometry(new ol.geom.Point(ol.proj.fromLonLat([29, 29]))); 
     //console.log(value); 
     vectorSource1.addFeature(featurething); 

回答

0

见默认ol.styleol.layer.Vectorhttp://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 
    }), 
}); 
+0

THX,所有正常工作 – Vic

相关问题