2014-09-25 73 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

相关问题