OL3是否支持WebGL上的Vector Tiles?

时间:2016-03-05 12:42:32

标签: webgl openlayers-3

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

以下来自OL3网站的示例仅在我删除“渲染器”时才有效。来自地图属性的属性,因此使用HTML5画布渲染地图: 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 个答案:

答案 0 :(得分:1)

只有画布渲染器支持带"""Pythonic way for Dependency Injection.""" from dependency_injector import providers from dependency_injector import injections @providers.DelegatedCallable def get_user_info(user_id): """Return user info.""" raise NotImplementedError() @providers.Factory @injections.inject(get_user_info=get_user_info) class AuthComponent(object): """Some authentication component.""" def __init__(self, get_user_info): """Initializer.""" self.get_user_info = get_user_info def authenticate_user(self, token): """Authenticate user by token.""" user_info = self.get_user_info(user_id=token + '1') return user_info print AuthComponent print get_user_info @providers.override(get_user_info) @providers.DelegatedCallable def get_user_info(user_id): """Return user info.""" return {'user_id': user_id} print AuthComponent().authenticate_user(token='abc') # {'user_id': 'abc1'} 的矢量切片。

答案 1 :(得分:0)

正如已经提到的,WebGL渲染目前只支持点,但肯定似乎希望将其扩展到线和多边形。由于VectorTile支持(仅授予画布)已经存在,我无法想象它们不包括完整的WebGL。

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

答案 2 :(得分:0)

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

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

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

相关问题