1

我正在使用 ol3 中的向量层,并且对 API Docs 确实缺乏进行了罚款。

唯一可用的参考是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'
      })
    })

  })
];

为什么会有数组?

如何更改字体大小?“字体大小”:和大小:没用

我应该查看其他一些文档吗?

我迷路了。

4

1 回答 1

3

请参阅http://openlayers.org/en/v3.0.0/apidoc/ol.layer.Vector.htmlstyle构造函数选项以查看支持的内容)。

它可以是一种样式,如果您想要一个功能的多种样式,则可以是一组样式,也可以是返回样式的函数(所有这些都将在内部转换为样式函数)。对于您提供的代码,不需要将单个值嵌套在数组中。

对于大小,font必须使用属性:将其用作 cssfont值(font: '12px Calibri,sans-serif'。参见示例(https://github.com/openlayers/ol3/blob/master/examples/vector-layer.js#L23)。

于 2014-09-26T12:50:57.443 回答