Question on drawing a heatmap

Hi all, I need to make a heatmap from json data and render it on the map.

Currently my idea is to draw a heatmap on a hidden canvas using a heatmap javascript plugin, then save the canvas as an image file, and finally render the image on the map.

However I found that I cannot draw on a hidden canvas. So I am wondering how I can draw an image underground and save it while loading the map?

Thanks for your help!

I’m not sure what you mean by a hidden canvas? Does the tool you’re using require the canvas be added to the dom? If not there shouldn’t be anything special you need to do. If you absolutely have to add it to the dom, then you could try setting a z index so that it is under everything else (and effectively hidden even if it’s not CSS hidden. We draw to canvases all of the time in Cesium (for example the writeTextToCanvas function and PinBuilder).

I assume you are using heatmap js? I’ve been meaning to play with it but haven’t had a chance yet.