Here i am using Openlayer3 to show the map in my website, the way suggested by it's documentation here to export the PNG format of the map i encounter an error in console saying the operation is insecure.
`document.getElementById('export-png').addEventListener('click', function() {
map.once('postcompose', function(event) {
var canvas = event.context.canvas;
if (navigator.msSaveBlob) {
navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
} else {
canvas.toBlob(function(blob) {
saveAs(blob, 'map.png');
});
}
});
map.renderSync();
});`
The canvas.toBlob function says SecurityError:the operation is insecure. the solution to this problem has been given as setting crossOrigin:'anonymous' here,but that doesn't solve the issue.