File tree Expand file tree Collapse file tree 5 files changed +826
-0
lines changed Expand file tree Collapse file tree 5 files changed +826
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,39 @@ L.U.UpdatePermsAction = L.U.BaseAction.extend({
86
86
} ,
87
87
} )
88
88
89
+ L . U . PrintAction = L . U . BaseAction . extend ( {
90
+
91
+ options : {
92
+ className : 'print-map dark' ,
93
+ tooltip : L . _ ( 'Print the current view' )
94
+ } ,
95
+
96
+ addHooks : function ( ) {
97
+ // dom-to-image creates the image from the map which is then inserted
98
+ // and opened within a new tab to be able to print it, we close the
99
+ // window in case the body regain the focus (printing cancelled).
100
+ domtoimage
101
+ . toPng ( this . map . _container )
102
+ . then ( function ( dataUrl ) {
103
+ var win = window . open ( 'about:blank' , "_new" ) ;
104
+ win . document . open ( ) ;
105
+ win . document . write ( `
106
+ <html>
107
+ <body
108
+ onload="window.print()"
109
+ onafterprint="window.close()"
110
+ onfocus="window.close()"
111
+ >
112
+ <img src="${ dataUrl } " style="max-width: 100%;"/>
113
+ </body>
114
+ </html>
115
+ ` ) ;
116
+ win . document . close ( ) ;
117
+ } ) ;
118
+ }
119
+
120
+ } ) ;
121
+
89
122
L . U . DrawMarkerAction = L . U . BaseAction . extend ( {
90
123
options : {
91
124
helpMenu : true ,
You can’t perform that action at this time.
0 commit comments