【问题标题】:Does OL3 support Vector Tiles on WebGL?OL3 是否支持 WebGL 上的矢量平铺?
【发布时间】:2016-06-19 06:18:28
【问题描述】:

OpenLayers 3 是否支持 WebGL 上的 LineString 和 Polygon 渲染?我已将渲染器设置为 'webgl' 并尝试渲染 TopoJSON 格式的 Vector Tile,但出现以下错误:“Uncaught TypeError: vectorSource.loadFeatures is not a function”。

以下来自 OL3 网站的示例仅在我从地图属性中删除“渲染器”属性时才有效,以便使用 HTML5 画布渲染地图: var map = new ol.Map({ renderer: 'webgl', layers: [ new ol.layer.VectorTile({ source: new ol.source.VectorTile({ attributions: [new ol.Attribution({ html: '© @987654321@ ' + '© @987654322@' })], format: new ol.format.MVT(), tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}), tilePixelRatio: 16, url: 'http://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/' + '{z}/{x}/{y}.vector.pbf?access_token=' + key }) }) ], target: 'map', view: new ol.View({ center: [0, 0], zoom: 2 }) });

【问题讨论】:

  • 你检查过github wiki entry这个吗?
  • 另外添加一些示例代码。
  • 并针对ol-debug.js(而不是缩小的ol.js)运行您的代码,这会为您提供更易读的错误消息
  • @rbaleksandar 该信息写于 2013 年 2 月 5 日,似乎是初步设计文件。
  • @rbaleksandar 示例已添加。

标签: webgl openlayers-3


【解决方案1】:

只有画布渲染器支持带有ol.layer.VectorTile 的矢量图块。

【讨论】:

  • 谢谢。 WebGL 上是否有任何 LineString 渲染支持? WebGL 是否计划支持矢量图块?
  • 在 3.2x 中是否有带有线和多边形特征的 webgl 示例?
  • 在 Openlayers 3.20 中添加了 Webgl 多边形支持 - 我仍然遇到同样的错误。矢量切片将来会与 webgl 渲染一起使用吗?
【解决方案2】:

如前所述,WebGL 渲染目前仅支持点,但似乎确实希望将其扩展到线和多边形。有了 VectorTile 支持(仅授予画布)已经存在,我无法想象它们不包括完整的 WebGL。

去年进行了一次代码冲刺,他们进行了概念验证。有许多限制,但事实证明这是可能的。 http://www.camptocamp.com/en/actualite/openlayers-3-towards-drawing-lines-and-polygons-with-webgl/

【讨论】:

    【解决方案3】:
    renderer    ol.renderer.Type | Array.<ol.renderer.Type> | undefined 
    

    渲染器。默认情况下,Canvas 和 WebGL 渲染器按此顺序进行支持测试,并使用第一个支持的渲染器。在此处指定 ol.renderer.Type 以使用特定的渲染器。请注意,Canvas 渲染器完全支持矢量数据,但 WebGL 只能渲染点几何图形。

    http://openlayers.org/en/latest/apidoc/ol.Map.html

    【讨论】:

      猜你喜欢
      • 2017-03-07
      • 2016-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-25
      相关资源
      最近更新 更多