I'm using this method to convert the Map containing WMS layer to image later use that image in PDF. Everything is working fine for WFS layers but not with WMS layers.

function CaptureImage()
    map.once('postcompose', function(event) 
               var canvas = event.context.canvas; 
               if (navigator.msSaveBlob)

                    navigator.msSaveBlob(canvas.msToBlob(), 'map.png'); 



                       var imgData= new Image(); 
                       imgData = canvas.toDataURL("png"); 

                       // Later I'm saving this image, but this is 
                       //                 workingfor 
                         //   WFS but not WMS Layers ;

  • Please do help this one out. I'm stuck for WMS Layers and it's working fine for WFS – Ranjith Kumar Rama Mar 19 at 5:10
  • If map variabel contains WFS then the image is generated otherwise nothing is generated in case of WMS – Ranjith Kumar Rama Mar 19 at 5:16
  • It might be due to tainted canvas. If you are using an external WMS you will need crossOrigin: 'Anonymous' in the source options to access the canvas. – Mike Mar 19 at 9:43
  • @Mike I have tried this one but still nothing is working. Thank you Mike – Ranjith Kumar Rama Mar 20 at 4:33
  • Convert WMS Layers into Image perhaps the issue centres around the fact <blink>that a WMS layer is already an image</blink>, so no conversion is required. – nmtoken Apr 1 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.