Google Map is not displayed when using html2canvas

Viewed 3524

I have done the screenshot button that have to make the screenshot of all body.

But on this screenshot google map is not dispayed. I used html2canvas library to do this. Here is the code :

HTML:

 <button type="button" class="btn btn-default btn-sm" id = 'screenShotBtn' onclick="takeScreenShot()"> 

JAVASCRIPT :

var takeScreenShot = function() {
var screenshot = {};
html2canvas(document.getElementById('screenAll'), {
    onrendered: function (canvas) {
        var tempcanvas=document.createElement('canvas');
        tempcanvas.width=1350;
        tempcanvas.height=700;
        var context=tempcanvas.getContext('2d');
        context.drawImage(canvas,0,0,1350,700,0,0,1350,700);
        var link=document.createElement("a");
        link.href=tempcanvas.toDataURL('image/jpg');   //function blocks CORS
        link.download = 'screenshot.jpg';
        link.click();
    }
});

And here is what I have when make the screenshot:

look here for screenshot

can you please tell me whats wrong?

2 Answers
    var fin = document.getElementById("map");

    html2canvas(fin, {
    useCORS: true,
    onrendered: function(canvas) {
        var dataUrl= canvas.toDataURL("image/png");
        $('#map_image').attr('src',dataUrl).show();
    }
  });
Related