Try
function printFunction() { html2canvas(document.getElementById("map"), { onrendered: function (canvas) { var img = canvas.toDataURL("image/png") window.open(img); } });
This works for me. Hashtag authentication only works for jQuery, it took me a while to figure it out :-)
However, there is a small problem. Html2canvas did not display the background WMS layer — only the map window and markers, so some configuration needs to be done.
Update : I worked a bit with this and I don't think it will work with openlayers. Since the openlayers map is a composition of many divs, it seems that html2canvas is not able to display all of them correctly. In particular, the WMS level, which when trying to do it by itself returns an error. You can try to make one of the child divs on the map, but this did not work for me. Although, if you use only simple vector graphics, this may work for you.
source share