I've tried to resolve the next error but without success.
I have the following jQuery and HTML5 code:
<script language="javascript" type="text/javascript">
function doExportMap() {
map.once('postcompose', function(event) {
var canvas = event.context.canvas;
var exportBMPElement = document.createElement('a');
exportBMPElement.download = 'Mapa.bmp';
exportBMPElement.href = canvas.toDataURL('image/bmp');
document.body.appendChild(exportBMPElement);
exportBMPElement.click();
document.body.removeChild(exportBMPElement);
});
map.renderSync();
}
It was working perfectly way, but now, I'm getting the following error:
SecurityError: The operation is insecure.
exportBMPElement.href = canvas.toDataURL('image/bmp');
What is wrong? Any ideas?
The funny is that I'm not loading the image from an external source. The image is from localhost
ctx.getImageData
orctx.toDataURL
. The browser automatically taints the canvas as a way to protect users from having their private information taken through malicious scripts using getImageData (for example, the user's banking login screen). Here's a link to more info about this security restriction: developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image – Coextensive'crossOrigin':'anonymous'
in one of your tile sources or your tile servers do not support CORS. – Morbihan