1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
| define([
| 'dojo/_base/declare',
| 'dojo/_base/lang',
| 'dojo/_base/array',
| 'dojo/_base/html',
| 'dojo/topic',
| 'jimu/BaseWidget',
| 'jimu/BaseWidget',
| './jqprint',
| ],
| function (declare,
| lang,
| array,
| html,
| topic,
| BaseWidget,
| jqprint
| ) {
| return declare([BaseWidget], {
| baseClass: 'jimu-widget-MapPrinting',
| name: 'MapPrinting',
| startup: function () {
| var that = this;
| // 点击面板X关闭面板
| $('.MapPrinting-flex-x').on('click', function () {
| $('.MapPrinting').hide();
| })
|
| // 存为图片
| $('.MapPrinting-left-cunwei').on('click', function () {
| printscreenScene()
| })
|
| // 打印
| $(".MapPrinting-right").on('click', function () {
| print_voucher()
| })
|
| // 打印方法
| function print_voucher() {
| print("cesiumContainer");
| }
|
| // 存为图片方法
| function printscreenScene() {
| var image = new Image();//创建img对象
| viewer.render();//重新渲染界面
| image = viewer.scene.canvas.toDataURL("image/png");
| $("#printscreenScene_save").find("img").attr("src", image);//添加img标签元素
| $("#printscreenScene_save img").show().addClass("show");
| saveFile(image, '场景出图');//调用打印图件函数
|
| }
| //打印图件
| var saveFile = function (data, filename) {
| var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
| save_link.href = data;
| save_link.download = filename;
|
| var event = document.createEvent('MouseEvents');
| event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
| save_link.dispatchEvent(event);
|
| };
| },
|
| onOpen: function () {
|
| },
|
|
| onClose: function () {
| //面板关闭的时候触发 (when this panel is closed trigger)
| },
|
| onMinimize: function () {
| this.resize();
| },
|
| onMaximize: function () {
| this.resize();
| },
|
| resize: function () {
|
| },
|
| destroy: function () {
| //销毁的时候触发
| //todo
| //do something before this func
| this.inherited(arguments);
| }
|
| });
| });
|
|