2014-09-25 85 views
1

我正在使用ol3中的矢量圖層,並且罰款了真正缺乏的API文檔。開放圖層中的樣式矢量3

唯一可用的參考是默認的樣式,展現在ol.style

這是我到目前爲止,從實例和試錯採取

style = [ 
    new ol.style.Style({ 

    image: new ol.style.Circle({ 
     radius: Math.max(10*log10(size), 10), 
     stroke: new ol.style.Stroke({ 
     width: 1.5, 
     color: '#fff' 
     }), 
     fill: new ol.style.Fill({ 
     color: 'hsl(220,60%,60%)' 
     }) 
    }), 

    text: new ol.style.Text({ 
     text: size.toString(), 
     fill: new ol.style.Fill({ 
     color: '#fff' 
     }) 
    }) 

    }) 
]; 

爲什麼會有一個數組?

如何更改字體大小? 「font-size」:和大小:沒有工作

是否還有其他文檔我應該看?

我迷路了。

+1

提示:。取消選擇「僅穩定」校驗查看API文檔時.. 。你會發現它們相當完整。 – ProfNimrod 2014-10-27 20:13:25

回答

2

請參閱http://openlayers.org/en/v3.0.0/apidoc/ol.layer.Vector.htmlstyle構造函數的選項以查看所支持的內容)。

它可以是一種風格,一種風格的數組,如果您想要一種功能的多種風格,或者一種返回風格的功能(所有這些都將在內部轉換爲風格功能)。 對於您提供的代碼,將不需要的數組嵌套到數組中。

對於大小,font屬性必須使用:使用它作爲一個css font值(font: '12px Calibri,sans-serif'參見實施例(https://github.com/openlayers/ol3/blob/master/examples/vector-layer.js#L23

+0

但是,文檔寫錯了。http://openlayers.org/en/v3.0.0-beta.1/apidoc/ol.style.Text.html說ol.style.Text可以在參數中使用http://openlayers.org/en/v3.0.0-beta.1/apidoc/ol.style.html#TextOptions,然而fontSize不起作用。 – petur 2014-10-23 07:26:57

+0

@petur這是beta1。3.0文檔的過時文檔是http://openlayers.org/en/v3.0.0/apidoc/ol.style.Text.html – tonio 2014-10-23 11:18:10

+0

是啊,哈哈!好。空文件只是可愛的。 – petur 2014-10-23 11:38:39

相關問題