openlayer地图打印功能
https://openlayers.org/en/v4.6.5/examples/export-map.html?mode=advanced&q=export
直接用官方例子时遇到了问题:Tainted canvases may not be exported. 解决方法如下:
系统地图打印是比较常用的功能,因为经常会把当前的视图作为图片保存,用于方便自己或者他人查看当前地图的情况,截图效果不是很好,直接使用openlayers官网例子。
https://blog.youkuaiyun.com/xcymorningsun/article/details/84859374
//注意添加:crossOrigin: 'anonymous'
var tilePolyline = new ol.layer.Tile({
//visible: false,
source: new ol.source.TileWMS({
url: 'http://localhost:8080/geoserver/whuxcy/wms',
params: {'FORMAT': format,
'VERSION': '1.1.1',
tiled: true,
"STYLES": '',
"LAYERS": 'whuxcy:polyline'
//"exceptions": 'application/vnd.ogc.se_inimage',
//tilesOrigin: 8176078.237520734 + "," + 704818.0275364731
},
crossOrigin: 'anonymous'
})
});