简体   繁体   中英

unable to screenshot google maps using html2canvas

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.

通过->“useCORS”解决:true,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM