首页 > 解决方案 > 将具有 WMS 图层的地图转换为图像并在 PDF 中使用它,但它适用于 WFS 图层

问题描述

我正在使用这种方法将包含 WMS 图层的地图转换为图像,然后在 PDF 中使用该图像。WFS 层一切正常,但 WMS 层不行。

function CaptureImage() {
    map.once('postcompose', function(event) {
        console.log(event);
        var canvas = event.context.canvas;
        console.log(canvas);

        if (navigator.msSaveBlob) {
            navigator.msSaveBlob(canvas.msToBlob(), 'map.png');

        } else {
            canvas.toBlob(function(blob) {
                var imgData = new Image();
                imgData = canvas.toDataURL("png");

                // Later I'm saving this image, but this is working for WFS, but not WMS Layers ;
            });
        }
    });
}

标签: javascriptopenlayers

解决方案


推荐阅读