简体   繁体   中英

Does OL3 support Vector Tiles on WebGL?

Does OpenLayers 3 support LineString and Polygon rendering on WebGL? I have set renderer to 'webgl' and tried to render a TopoJSON format Vector Tile but got the following error: "Uncaught TypeError: vectorSource.loadFeatures is not a function".

The following example from the OL3 web site only works if i remove the 'renderer' attribute from the map properties so the map is rendered using an HTML5 canvas: var map = new ol.Map({ renderer: 'webgl', layers: [ new ol.layer.VectorTile({ source: new ol.source.VectorTile({ attributions: [new ol.Attribution({ html: '© Mapbox ' + '© ' + 'OpenStreetMap contributors ' })], format: new ol.format.MVT(), tileGrid: ol.tilegrid.createXYZ({maxZoom: 22}), tilePixelRatio: 16, url: 'http://{ad}.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 }) });

仅画布渲染器支持带有ol.layer.VectorTile矢量切片。

As already mentioned, only points are currently supported for WebGL rendering, but there certainly appears to be a desire to expand this out to lines and polygons. With the VectorTile support (granted canvas only) already being there, I couldn't imagine them not including full WebGL.

There was a code sprint last year where they did a proof of concept. There were a number of limitations, but it proved it was possible. http://www.camptocamp.com/en/actualite/openlayers-3-towards-drawing-lines-and-polygons-with-webgl/

renderer    ol.renderer.Type | Array.<ol.renderer.Type> | undefined 

Renderer. By default, Canvas and WebGL renderers are tested for support in that order, and the first supported used. Specify a ol.renderer.Type here to use a specific renderer. Note that the Canvas renderer fully supports vector data, but WebGL can only render Point geometries.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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