I'm using the following code which I would like to create a button when pressed it would take a screenshot of the google map and download it as an image.
Currently when button is pressed nothing is happening.
Here is my current code:
function scrshot() {
html2canvas(document.getElementById("map"), {
useCORS: true,
onrendered: function(canvas) {
var a = document.createElement('a');
a.href = canvas.toDataURL("image/png");
a.download = 'portal_scrshot.png';
a.click();
//window.open().document.write('<img src="' + canvas.toDataURL() + '" />');
}
});
}
When I removed useCORS and onrendered I get a screenshot but the google maps is blank.