From 88bbb8c1ae64f52ac526bb87100fc9d772d3850e Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 24 Oct 2019 13:52:59 +0200 Subject: [PATCH] Clamp the weight value between 0 and 1 --- src/ol/layer/Heatmap.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ol/layer/Heatmap.js b/src/ol/layer/Heatmap.js index 4cbcf0a6ce..646777a0d3 100644 --- a/src/ol/layer/Heatmap.js +++ b/src/ol/layer/Heatmap.js @@ -4,6 +4,7 @@ import {getChangeEventType} from '../Object.js'; import {createCanvasContext2D} from '../dom.js'; import VectorLayer from './Vector.js'; +import {clamp} from '../math.js'; import {assign} from '../obj.js'; import WebGLPointsLayerRenderer from '../renderer/webgl/PointsLayer.js'; @@ -180,7 +181,10 @@ class Heatmap extends VectorLayer { attributes: [ { name: 'weight', - callback: this.weightFunction_ + callback: function(feature) { + const weight = this.weightFunction_(feature); + return weight !== undefined ? clamp(weight, 0, 1) : 1; + }.bind(this) } ], vertexShader: `