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