1
votes

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://{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 }) });

3
Have you checked the github wiki entry on this? - rbaleksandar
Also add some sample code. - rbaleksandar
And run your code against ol-debug.js (instead of the minified ol.js), which gives you more readable error messages - Sidney Gijzen
@rbaleksandar That info was written on Feb 5, 2013 and seems to be a preliminary design document. - Oscar
@rbaleksandar sample added. - Oscar

3 Answers

1
votes

Only the canvas renderer supports vector tiles with ol.layer.VectorTile.

0
votes

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/

0
votes
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