Openlayer map printing function

Openlayer map printing function

https://openlayers.org/en/v4.6.5/examples/export-map.html?mode=advanced&q=export

I encountered a problem when directly using the official example: Tainted canvases may not be exported. The solution is as follows:

 

 

System map printing is a commonly used function, because the current view is often saved as a picture to facilitate the viewing of the current map by yourself or others. The screenshot effect is not very good. Use the openlayers official website example directly.

https://blog.csdn.net/xcymorningsun/article/details/84859374

//Note to add: 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'
        })
    });

 

Guess you like

Origin blog.csdn.net/qq503690160/article/details/94716236