openlayer地圖打印功能

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.csdn.net/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'
        })
    });

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章