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() {
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
});
}
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>
source
share