Merge pull request #11545 from fredj/webgl_className
Use the className param in ol.layer.Heatmap
This commit is contained in:
@@ -182,6 +182,7 @@ class Heatmap extends VectorLayer {
|
|||||||
*/
|
*/
|
||||||
createRenderer() {
|
createRenderer() {
|
||||||
return new WebGLPointsLayerRenderer(this, {
|
return new WebGLPointsLayerRenderer(this, {
|
||||||
|
className: this.getClassName(),
|
||||||
attributes: [
|
attributes: [
|
||||||
{
|
{
|
||||||
name: 'weight',
|
name: 'weight',
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class WebGLPointsLayer extends Layer {
|
|||||||
*/
|
*/
|
||||||
createRenderer() {
|
createRenderer() {
|
||||||
return new WebGLPointsLayerRenderer(this, {
|
return new WebGLPointsLayerRenderer(this, {
|
||||||
|
className: this.getClassName(),
|
||||||
vertexShader: this.parseResult_.builder.getSymbolVertexShader(),
|
vertexShader: this.parseResult_.builder.getSymbolVertexShader(),
|
||||||
fragmentShader: this.parseResult_.builder.getSymbolFragmentShader(),
|
fragmentShader: this.parseResult_.builder.getSymbolFragmentShader(),
|
||||||
hitVertexShader:
|
hitVertexShader:
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export const WebGLWorkerMessageType = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
|
* @property {string} [className='ol-layer'] A CSS class name to set to the canvas element.
|
||||||
* @property {Object.<string,import("../../webgl/Helper").UniformValue>} [uniforms] Uniform definitions for the post process steps
|
* @property {Object.<string,import("../../webgl/Helper").UniformValue>} [uniforms] Uniform definitions for the post process steps
|
||||||
* @property {Array<PostProcessesOptions>} [postProcesses] Post-processes definitions
|
* @property {Array<PostProcessesOptions>} [postProcesses] Post-processes definitions
|
||||||
*/
|
*/
|
||||||
@@ -65,6 +66,10 @@ class WebGLLayerRenderer extends LayerRenderer {
|
|||||||
postProcesses: options.postProcesses,
|
postProcesses: options.postProcesses,
|
||||||
uniforms: options.uniforms,
|
uniforms: options.uniforms,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (options.className !== undefined) {
|
||||||
|
this.helper.getCanvas().className = options.className;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import {listen, unlistenByKey} from '../../events.js';
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Options
|
* @typedef {Object} Options
|
||||||
|
* @property {string} [className='ol-layer'] A CSS class name to set to the canvas element.
|
||||||
* @property {Array<CustomAttribute>} [attributes] These attributes will be read from the features in the source and then
|
* @property {Array<CustomAttribute>} [attributes] These attributes will be read from the features in the source and then
|
||||||
* passed to the GPU. The `name` property of each attribute will serve as its identifier:
|
* passed to the GPU. The `name` property of each attribute will serve as its identifier:
|
||||||
* * In the vertex shader as an `attribute` by prefixing it with `a_`
|
* * In the vertex shader as an `attribute` by prefixing it with `a_`
|
||||||
@@ -131,6 +132,7 @@ class WebGLPointsLayerRenderer extends WebGLLayerRenderer {
|
|||||||
uniforms[DefaultUniform.PROJECTION_MATRIX] = projectionMatrixTransform;
|
uniforms[DefaultUniform.PROJECTION_MATRIX] = projectionMatrixTransform;
|
||||||
|
|
||||||
super(layer, {
|
super(layer, {
|
||||||
|
className: options.className,
|
||||||
uniforms: uniforms,
|
uniforms: uniforms,
|
||||||
postProcesses: options.postProcesses,
|
postProcesses: options.postProcesses,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,21 @@ describe('ol.layer.Heatmap', function () {
|
|||||||
const instance = new HeatmapLayer();
|
const instance = new HeatmapLayer();
|
||||||
expect(instance).to.be.an(HeatmapLayer);
|
expect(instance).to.be.an(HeatmapLayer);
|
||||||
});
|
});
|
||||||
|
it('has a default className', function () {
|
||||||
|
const layer = new HeatmapLayer({
|
||||||
|
source: new VectorSource(),
|
||||||
|
});
|
||||||
|
const canvas = layer.getRenderer().helper.getCanvas();
|
||||||
|
expect(canvas.className).to.eql('ol-layer');
|
||||||
|
});
|
||||||
|
it('accepts a custom className', function () {
|
||||||
|
const layer = new HeatmapLayer({
|
||||||
|
source: new VectorSource(),
|
||||||
|
className: 'a-class-name',
|
||||||
|
});
|
||||||
|
const canvas = layer.getRenderer().helper.getCanvas();
|
||||||
|
expect(canvas.className).to.eql('a-class-name');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hit detection', function () {
|
describe('hit detection', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user