简体   繁体   English

如何在openlayers中定义webgl点的大小?

[英]How to define size of a webgl-point in openlayers?

I created circles using webgl point layer, but I don't know how to change size.我使用 webgl 点图层创建了圆圈,但我不知道如何更改大小。 How do I do that?我怎么做? Base link: https://openlayers.org/en/latest/examples/webgl-points-layer.html My style are below:基本链接: https : //openlayers.org/en/latest/examples/webgl-points-layer.html我的风格如下:

style: {
    symbol: {
      symbolType: 'circle',
      size: [
        "interpolate",
        [
          "exponential",
          2.5
        ],
        [
          "zoom"
        ],
        2,
        1,
        14,
        32
      ],
      color: 'rgba(255,0,0,0.5)'
    }
  }

I need the behavior to be the same as these circles: http://smartcitybr-app-isolated-functions.s3-website-us-east-1.amazonaws.com/index.html我需要与这些圈子的行为相同: http : //smartcitybr-app-isolated-functions.s3-website-us-east-1.amazonaws.com/index.html

It works in the example, although the size does not increase above zoom 14. You could change the max zoom and size if you wanted, also reducing the exponent base to 2 makes the transition better relate to the changing resolution.它在示例中有效,尽管大小不会增加到缩放 14 以上。如果需要,您可以更改最大缩放和大小,还将指数基数减少到 2 使转换更好地与不断变化的分辨率相关。

"size": [
  "interpolate",
  [
    "exponential",
    2
  ],
  [
    "zoom"
  ],
  2,
  1,
  28,
  256
],

The only polygons directly supported are triangle and square.唯一直接支持的多边形是三角形和正方形。 They can be scaled in both dimensions as well as rotated, so you could get a rectangle using:它们可以在两个维度上进行缩放和旋转,因此您可以使用以下方法获得一个矩形:

  "symbolType": "square",
  "size": ["array", ["/", 2000, ["resolution"]], ["/", 1000, ["resolution"]]],

For more complex polygons you would need to use "symbolType": "image", and supply an icon src which could be a dataURL for something you draw on a 2d canvas, or you could use OpenLayers to produce the shape, for example:对于更复杂的多边形,您需要使用"symbolType": "image",并提供一个图标 src,它可以是您在 2d 画布上绘制的内容的 dataURL,或者您可以使用 OpenLayers 来生成形状,例如:

  symbolType: 'image',
  src: new RegularShape({
    fill: new Fill({color: 'red'}),
    stroke: new Stroke({color: 'black', width: 1}),
    points: 5,
    radius: 10,
    radius2: 4,
    angle: 0,
  }).getImage(10).toDataURL(),
  "size": ["/", 1000, ["resolution"]],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM