I need to get an image from a canvas that is filled with a google map:
...
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
...
var canvas = document.getElementById("map-canvas");
var ctx=canvas.getContext("2d");
var url = canvas.toDataURL();
Doesn't work. It's broke up at the second line "var ctx=canvas.getContext("2d");"
. Can anybody help me? Is there a other way to have the same effect?
You can't do this. Your element map-canvas
isn't a canvas element ; it's just an element with an id 'map-canvas'. Canvas methods only work on <canvas>
elements.
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.