|
|
|
@ -5,7 +5,8 @@ import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dial
|
|
|
|
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
declare var QRCode: any; |
|
|
|
|
|
|
|
|
|
declare var html2canvas: any; |
|
|
|
|
// import html2canvas from 'html2canvas';
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-gis-labeling', |
|
|
|
|
templateUrl: './gis-labeling.component.html', |
|
|
|
@ -156,6 +157,43 @@ export class GisLabelingComponent implements OnInit {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//生成图片
|
|
|
|
|
canvasImg |
|
|
|
|
createimg(){ |
|
|
|
|
|
|
|
|
|
// 使用html2canvas插件,将数据源中的数据转换成画布。
|
|
|
|
|
html2canvas(document.querySelector("#map"),{ |
|
|
|
|
useCORS: true, // 【重要】开启跨域配置,
|
|
|
|
|
allowTaint: true,//允许跨域图片
|
|
|
|
|
taintTest: false,//是否在渲染前测试图片
|
|
|
|
|
onrendered: function(canvas) { |
|
|
|
|
var dataUrl = canvas.toDataURL("image/png"); |
|
|
|
|
} |
|
|
|
|
}).then(canvas => { |
|
|
|
|
// 修改生成的宽度
|
|
|
|
|
// canvas.style.width = "1000px";
|
|
|
|
|
console.log(canvas, "生成的画布文件"); |
|
|
|
|
this.canvasImg = canvas.toDataURL("image/png"); |
|
|
|
|
// console.log(this.canvasImg)
|
|
|
|
|
}).then(()=>{ |
|
|
|
|
this.downloadFile("导出图片", this.canvasImg); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
downloadFile(filename, content) { |
|
|
|
|
var base64Img = content; |
|
|
|
|
var oA = document.createElement('a'); |
|
|
|
|
oA.href = base64Img; |
|
|
|
|
oA.download = filename; |
|
|
|
|
var event = document.createEvent('MouseEvents'); |
|
|
|
|
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
|
|
|
|
oA.dispatchEvent(event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//构造重点单位checkbox控制器
|
|
|
|
|
buildUnits() { |
|
|
|
|
const arr = this.keyUnitList.map(item => { |
|
|
|
|