无法使用 ESRI Javascript API 和 html2canvasa 打印地图 div

Unable to ESRI Javascript API and html2canvasa to print off map div

我无法让 html2canvas 与 ESRI Javascript API 界面一起工作。除了地图内容外,它将正确打印页面上显示的所有内容。

有没有人知道如何进行这项工作,如果可以,您能提供一个例子吗?

如果您无法完成这项工作,您使用了什么解决方案来创建整个页面的屏幕截图,以便您的用户正确打印他们正在查看的内容?

在不太了解您的具体用例的情况下,我猜该地图是由托管在与您的站点不同的域中的图像组成的。因此,html2canvas 很可能 运行 进入 same origin policy 并且无法读取这些图像。

来自 html2canvas 文档:

"All the images that the script uses need to reside under the same origin for it to be able to read them without the assistance of a proxy. Similarly, if you have other canvas elements on the page, which have been tainted with cross-origin content, they will become dirty and no longer readable by html2canvas."

不过,他们确实有设置代理以获取 cross-origin 图像的选项,以及尝试使用 CORS headers 加载图像的选项。在 documentation.

中检查 "proxy" 和 "useCORS" 选项