I've tried creating the google map to image using html2canvas js and it is not working. I'm getting the error on console as "Element is not attached to a Document".
I've tried multiple functions of js for creating the canvas but none seems to work.
I've created images from canvas so if I can create the map into canvas this would also help.
Here '#closest_map' is the google map generated. PLz go through my snippets and suggest what's going wrong.
<html>
<head></head>
<body>
<script>
///all the below snippets givs the same result
var element = $("#closest_map");
html2canvas(element, {
useCORS: true,
onrendered: function(canvas) {
var dataUrl = canvas.toDataURL("image/png");
document.write('<img src="' + dataUrl + '"/>');
}
});
html2canvas($('#closest_map').get(0)).then(function(canvas) {
var base64encodedstring = canvas.toDataURL("image/jpeg", 1);
$('#img').attr('src', base64encodedstring);
});
</script>
</body>
</html>
Update I was able to create the images by using version html2canvas 4.0 js but now the marker which were circle in shape doesn't render out perfect circles. If a use a slightly higher JS like 5.0 I get the perfect circles but the map does not show up. just a cream coloured square holding my markers.