Feature

问题描述 投票:0回答:1
, ...

There is no easy solution for irregular shapes, but if your shapes are rectangles you would need to consider their width and height, along with the maximum number of lines and characters in a line

function setStyle(feature: RenderFeature | Feature<any>, resolution: number): void | Style | Style[] {
  const props: IProps = feature.getProperties()
  const options: IStyleOptions = this.styleOptions(props)
  // const area: number = feature.getGeometry().getArea()
  const fontSize: number = Math.floor(1 / resolution)
  const style: Style = new Style({
    fill: new Fill({
      color: options.fillColor
    }),
    stroke: new Stroke({
      color: options.strokeColor,
      width: 1
    }),
    text: new Text({
      font: `bold ${fontSize}px/1 Malgun Gothic`,
      text: options.text,
      overflow: true
    })
  })
  return style
}

我使用Openlayers来绘制字符和形状,我想根据形状的大小动态地改变字符的大小。

我想根据形状的大小动态地改变字符的大小。
openlayers openlayers-6
1个回答
1
投票

我使用Openlayers来绘制字符和形状,我想根据形状的大小动态地改变字符的大小。我想根据形状的大小动态地改变字符的大小。RenderFeature

© www.soinside.com 2019 - 2024. All rights reserved.