OpenLayers版本5.3.0,在地图导出pdf时出现问题

问题描述

我使用openlayers版本5.3.0,并且我想导出地图pdf。问题在于导出时的地图范围不正确。打印高度错误。在openlayers(版本5.3.0)示例(https://openlayers.org/en/v5.3.0/examples/export-pdf.html?q=pdf)上,结果与我的相同。打印的地图高度大于地图的范围。我也在最新版本(https://openlayers.org/en/latest/examples/export-pdf.html)中进行了检查,这是绝对正确的。它精确地打印地图范围。如何在不更改版本的情况下将其修复?

谢谢。

// Reset original map size
map.setSize(size);
map.getView().fit(map.getView().calculateExtent(map.getSize()),{constrainResolution: false});
map.getView().setResolution(viewResolution);
document.body.style.cursor = 'auto';


// Set print size
let printSize = [width,height];
map.setSize(printSize);
let scaling = Math.min(width / size[0],height / size[1]);
map.getView().fit(map.getView().calculateExtent(map.getSize()),{ size: printSize,constrainResolution: false});
map.getView().setResolution(viewResolution/scaling);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)