MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / draw

Method draw

src/openlayers/overlay/HeatMap.js:230–251  ·  view source on GitHub ↗

* @function HeatMap.prototype.draw * @description 绘制热点图。 * @param {Array} data - convertToPixelPoints 方法计算出的点。 * @param {number} maxWeight -最大权重。 * @private

(data, maxWeight)

Source from the content-addressed store, hash-verified

228 * @private
229 */
230 draw(data, maxWeight) {
231 if (this.maxHeight > 0 && this.maxWidth > 0) {
232 //清空
233 var ctx = this.canvasContext;
234 this.canvasContext.clearRect(0, 0, this.maxWidth, this.maxHeight);
235 this.drawCircle(this.useRadius);
236 this.createGradient();
237
238 for (var i = 0; i < data.length; i++) {
239 var p = data[i];
240 this.canvasContext.globalAlpha = Math.max(p[2] / maxWeight, 0.05);
241 this.canvasContext.drawImage(this.circle, p[0] - this.useRadius, p[1] - this.useRadius);
242 }
243
244 var colored = ctx.getImageData(0, 0, this.maxWidth, this.maxHeight);
245 this.colorize(colored.data, this.grad);
246 ctx.putImageData(colored, 0, 0);
247 } else {
248 return false;
249 }
250
251 }
252
253 /**
254 * @function HeatMap.prototype.colorize

Callers 15

MapVLayerSpec.jsFile · 0.45
ThreeLayerSpec.jsFile · 0.45
mapbox-gl.jsFile · 0.45
YiFunction · 0.45
ioFunction · 0.45
ooFunction · 0.45
roFunction · 0.45
aoFunction · 0.45
noFunction · 0.45
goFunction · 0.45

Calls 4

drawCircleMethod · 0.95
createGradientMethod · 0.95
colorizeMethod · 0.95
maxMethod · 0.80

Tested by

no test coverage detected