2017-07-13 58 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

相關問題