Parse the style in the constructor.

This detects errors earlier and allows the caller to handle the thrown exception.
Remove assertion 65 as it should no longer be needed.
This commit is contained in:
Maximilian Krög committed 2019-10-03 14:36:48 +02:00
1 parent d0cd1064ff
commit b1a9f765fc
2 files changed
+10 -15

No files matched your search

-4
View File
@@ -241,10 +241,6 @@ Support for the `OES_element_index_uint` WebGL extension is mandatory for WebGL
Layer opacity must be a number.
### 65
A symbol literal representation must be defined on the style supplied to a `WebGLPointsLayer` instance.
### 66
`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled.
+10 -11
View File
@@ -4,7 +4,6 @@
import {assign} from '../obj.js';
import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js';
import {getSymbolFragmentShader, getSymbolVertexShader, parseSymbolStyle} from '../webgl/ShaderBuilder.js';
import {assert} from '../asserts.js';
import Layer from './Layer.js';
@@ -72,24 +71,24 @@ class WebGLPointsLayer extends Layer {
super(baseOptions);
/**
* @type {import('../style/LiteralStyle.js').LiteralStyle}
* @private
* @type {import('../webgl/ShaderBuilder.js').StyleParseResult}
*/
this.style = options.style;
assert(this.style.symbol !== undefined, 65);
this.parseResult_ = parseSymbolStyle(
/** @type {import('../style/LiteralStyle.js').LiteralStyle} */
(options.style).symbol
);
}
/**
* @inheritDoc
*/
createRenderer() {
const parseResult = parseSymbolStyle(this.style.symbol);
return new WebGLPointsLayerRenderer(this, {
vertexShader: getSymbolVertexShader(parseResult.params),
fragmentShader: getSymbolFragmentShader(parseResult.params),
uniforms: parseResult.uniforms,
attributes: parseResult.attributes
vertexShader: getSymbolVertexShader(this.parseResult_.params),
fragmentShader: getSymbolFragmentShader(this.parseResult_.params),
uniforms: this.parseResult_.uniforms,
attributes: this.parseResult_.attributes
});
}
}