用ol 地图打印 跨域 调用了天地图 iserver与项目会部署在两台服务器

0 投票
let terLayer = new ol.layer.Tile({
  crossOrigin: 'anonymous',
  visible: true,
  source: new ol.source.TileSuperMapRest({
    url: this.mapServerUrl + "/map-tianditu/rest/maps/地形底图_经纬度",
    transparent: true
  }),
  projection: 'EPSG:4326',
});
document.querySelectorAll('.ol-viewport canvas'),
function (canvas) {
  if (canvas.width > 0) {
    var opacity = canvas.parentNode.style.opacity;
    mapContext.globalAlpha = opacity === '' ? 1 : Number(opacity);
    // var transform = canvas.style.transform;
    // Get the transform parameters from the style's transform matrix
    /*var matrix = transform
      .match(/^matrix\(([^\(]*)\)$/)[1]
      .split(',')
      .map(Number);*/
    // Apply the transform to the export map context
    CanvasRenderingContext2D.prototype.setTransform.apply(
      mapContext,
      [1, 0, 0, 1, 0, 0]
    );
    mapContext.drawImage(canvas, 0, 0);
  }
}
12月 22, 2020 分类:  52次浏览 | 用户: sunmingyang1011 (4 分)

1个回答

0 投票

请详细描述一下您的问题呢?web打印请参考https://iclient.supermap.io/examples/openlayers/editor.html#webPrintingJob

12月 22, 2020 用户: 张亮 名扬四海 (2,086 分)
地图底图是天地图,打印地图 canvas转图片 提示跨域 无法打印 Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported. wo 我这里不是使用webmap
...