我正在使用Angular 8
我正在尝试导出使用openlayer创建的地图的图像/斑点,但我无法使其正常工作。我什至尝试将ViewChild与html2canvas一起使用,但随后我将除地图外的所有内容都放入了div中。
@ViewChild('download', { static: false }) public download: ElementRef;
pdfDownload() {
let domElement = this.download.nativeElement as HTMLElement;
console.log(domElement);
html2canvas(domElement).then(canvas => {
var imgData = canvas.toDataURL("image/png");
console.log(imgData); //here i get a blob that has everything from the div like buttons and so on, but not the map itself thats also inside this div
});
}
我确实看到了一些带有openlayer的javascript版本,他们设法在不使用其他库的情况下下载了它,但我无法设法将其翻译成打字稿。
知道如何使用openlayer或html2canvas lib使它正常工作的人吗?甚至还有mby吗?
由于基本相同,也尝试了以下操作,没有任何成功
pdfDownload() {
var cnvs = document.getElementById('map');
html2canvas(cnvs).then(canvas => {
var imgData = canvas.toDataURL("image/png");
console.log(imgData); //here i get a blob that has everything from the div like buttons and so on, but not the map itself thats also inside this div
});
}
您可以使用ol-ext print control将打印内容封装在控件中。