Basically, I'm writing a program that allows a user to create and export maps. I can't get JavaScript to export the map (a canvas) because it is "tainted." I tried looking this up and tried to fix the error multiple times in multiple ways, but nothing worked. Here is some of the code for exporting in case it helps:
<img id="exportImage" crossorigin="Anonymous">
<script>
function exportMap(){
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var img = document.getElementById("exportImage")
// save canvas image as data url (png format by default)
img.crossorigin = "Anonymous";
var dataURL = canvas.toDataURL();
console.log(dataURL)
document.getElementById("exportImage").src = dataURL;
}
</script>
Thanks in advance!