Skip canvas.toDataURL back to div

I am trying to capture a Streetview panorama image that appears in a Google maps infowindow window. I created a button that calls the captureImage () function, but I'm struggling to pass the var = img variable returned in HTML.

I think there is a problem with the variable "contentString" and "content", which are local. Should I write a captureImage () function in initialize ()? thank.

My code is as follows:

function initialize() {

//code here

    var contentString = '<input type="button" value="Grab this picture" onClick="captureImage()" /> <div id="content" style="width:300px;height:400px;"></div>';
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });

//code here

}

function captureImage()
{
    var canvas = document.getElementById("content");
    var img    = canvas.toDataURL("image/png");
    document.write('<img src="'+img+'"/>');

}   

HTML:

    <div id="dialog" title="Image box">
        <p>Here is the image from Streetview :</p>
                    <img scr=""></img>
    </div>
+3
source share
1 answer

It would be easier if I installed <img>src directly :

http://maps.googleapis.com/maps/api/streetview?size=<width>x<height>&location=lat,%20lng&fov=90&heading=235&pitch=10&sensor=false

0
source

All Articles