Tainted canvases may not be exported

后端 未结 10 1374
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 05:21

I want to save my canvas to a img. I have this function:

function save() {
    document.getElementById(\"canvasimg\").style.border = \"2px solid\";
    var d         


        
10条回答
  •  攒了一身酷
    2020-11-22 06:16

    If someone views on my answer, you maybe in this condition:

    1. Trying to get a map screenshot in canvas using openlayers (version >= 3)
    2. And viewed the example of exporting map
    3. Using ol.source.XYZ to render map layer

    Bingo!

    Using ol.source.XYZ.crossOrigin = 'Anonymous' to solve your confuse. Or like following code:

         var baseLayer = new ol.layer.Tile({
             name: 'basic',
             source: new ol.source.XYZ({
                 url: options.baseMap.basic,
                 crossOrigin: "Anonymous"
             })
         });
    

提交回复
热议问题