Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用html2canvas时,谷歌地图屏幕捕获无法正常工作_Javascript_Jquery_Google Maps_Screenshot_Html2canvas - Fatal编程技术网

Javascript 使用html2canvas时,谷歌地图屏幕捕获无法正常工作

Javascript 使用html2canvas时,谷歌地图屏幕捕获无法正常工作,javascript,jquery,google-maps,screenshot,html2canvas,Javascript,Jquery,Google Maps,Screenshot,Html2canvas,谷歌地图屏幕捕获无法正常工作。输出图像文件中出现灰色屏幕。对于div部分中的简单文本,可以使用它。有什么建议吗 我试着这样做: <!DOCTYPE html> <html> <head> <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false"> <script src="h

谷歌地图屏幕捕获无法正常工作。输出图像文件中出现灰色屏幕。对于div部分中的简单文本,可以使用它。有什么建议吗

我试着这样做:

<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js"></script> 
<script type="text/javascript" src ="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script type="text/javascript" src="html2canvas.js?rev032"></script> 
</script>


<script type="text/javascript">

function initialize()
    {
    var mapProp = {
          center:new google.maps.LatLng(51.508742,-0.120850),
          zoom:5,
          mapTypeId:google.maps.MapTypeId.ROADMAP
      };
    var map=new google.maps.Map(document.getElementById("googleMap"), mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);

$(window).load(function(){

    $('#load').click(function(){

            html2canvas($('#googleMap'), {
                onrendered: function (canvas) {
                    var dataURL = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
                    window.location.href = dataURL;
                }
            });

    });
});
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
<input type="button" value="Save" id="load"/>
</body>
</html> 
$(window).load(function(){

    $('#load').click(function(){

            html2canvas($('#googleMap'), {
            useCORS: true,
                onrendered: function (canvas) {
                var dataUrl= canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");

                window.location.href = dataUrl;
                                    }
            });

    });
});