version - 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);
解决方案
推荐阅读
- hyperledger-fabric - 我想构建一个 Hyperledger Fabric 网络,在多个组织的多个主机上运行
- java - 如何将临时授予的 ContentProvider 权限传递给 Service?
- c# - 登录网站并使用 Html Agility Pack 设置用户代理
- swift - 如何使用枚举创建计算函数?
- docker - Dockerfile 的第一行 - 什么操作系统?
- authorization - 为动态角色和属性建模 XACML 策略
- kubernetes - Traefik 入口不适用于集群 IP
- ionic-framework - 如何将我的 Ionic 4 应用程序升级到最新的 Ionic 版本?
- css - 如何使用来自其父级的 ::after 的通用兄弟选择器
- r - 使用 NA 删除行和列但保留 R 中的值