1

Here i am using Openlayer3 to show the map in my website, the way suggested by it's documentation here to export the PNG format of the map i encounter an error in console saying the operation is insecure.

`document.getElementById('export-png').addEventListener('click', function() {
        map.once('postcompose', function(event) {
          var canvas = event.context.canvas;
          if (navigator.msSaveBlob) {
            navigator.msSaveBlob(canvas.msToBlob(), 'map.png');
          } else {
            canvas.toBlob(function(blob) {
              saveAs(blob, 'map.png');
            });
          }
        });
        map.renderSync();
      });`

The canvas.toBlob function says SecurityError:the operation is insecure. the solution to this problem has been given as setting crossOrigin:'anonymous' here,but that doesn't solve the issue.

A Sahra
  • 118
  • 1
  • 12
  • If you get images from a non CORS server this example will not work. This includes all tiles or wms images within your map. OSM is CORS enabled but a local geoserver for example is not. – pavlos Oct 22 '17 at 09:36

0 Answers0