I try to export element to PNG image with Javascript, but I've the error message :
SecurityError: The operation is insecure.
I read on other forum, it's because the flag of my canvas is turn true. SO, do you know hwhere can I turn false the flag origin-clean ?
The button where I run my function :
<div id = "control_export_png">
<a id="control_link_export_png" download="extrait_carte_cclo.png" style="display:block;" crossOrigin="anonymous">
</a>
</div>
And my javascript:
var exportPNGElement = document.getElementById('control_link_export_png');
if ('download' in exportPNGElement) {
exportPNGElement.addEventListener('click', function(e) {
map.once('postcompose', function(event) {
var canvas = event.context.canvas;
exportPNGElement.href = canvas.toDataURL();
});
map.renderSync();
}, false);
}