@sswroom/sswr 1.6.19 → 1.6.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,739 @@
1
+ import * as data from "../data.js";
2
+ import * as math from "../math.js";
3
+ import * as web from "../web.js";
4
+ import * as domtoimage from "../domtoimage/index.js";
5
+
6
+ export class EasyPrint
7
+ {
8
+ /**
9
+ * @param {L.map} map
10
+ * @param {{title?: string, position?: string, sizeModes?: string[], filename?: string, exportOnly?: boolean, hidden?: boolean, tileLayer?: L.tileLayer|L.tileLayer[],tileWait?: number, hideControlContainer?: boolean, hideClasses?: string[], hideIds?: string[], pageBorderTopHTML?: string, pageBorderBottomHTML?: string, pageBorderHeight?: number, overlayHTML?: string, spinnerBgCOlor?: string, customSpinnerClass?: string}} options
11
+ */
12
+ constructor(map, options)
13
+ {
14
+ this._a4PageSize = {
15
+ height: 715,
16
+ width: 1045
17
+ };
18
+
19
+ this._a4PaperSize = {
20
+ width: 1123.660266,
21
+ height: 794.547794
22
+ };
23
+
24
+ this._a3PaperSize = {
25
+ width: 1589.095588,
26
+ height: 1123.660266
27
+ };
28
+
29
+ this._pageMargin = {
30
+ x: 40,
31
+ y: 40
32
+ };
33
+
34
+ this.blankDiv = null;
35
+ this._map = map;
36
+ this.options = data.mergeOptions(options, {
37
+ title: 'Print map',
38
+ position: 'topleft',
39
+ sizeModes: ['Current','A4Landscape','A4Portrait','A3Landscape','A3Portrait'],
40
+ sizeModeObjs: [],
41
+ filename: 'map',
42
+ exportOnly: false,
43
+ hidden: false,
44
+ tileLayer: null, //Layer[] | Layer
45
+ tileWait: 500,
46
+ hideControlContainer: true,
47
+ hideClasses: [],
48
+ hideIds: [],
49
+ onclick: null,
50
+ pageBorderTopHTML: null,
51
+ pageBorderBottomHTML: null,
52
+ pageBorderHeight: 0,
53
+ overlayHTML: null,
54
+ customWindowTitle: window.document.title,
55
+ spinnerBgCOlor: '#0DC5C1',
56
+ customSpinnerClass: 'epLoader',
57
+ defaultSizeTitles: {
58
+ Current: 'Current Size',
59
+ A4Landscape: 'A4 Landscape',
60
+ A4Portrait: 'A4 Portrait',
61
+ A3Landscape: 'A3 Landscape',
62
+ A3Portrait: 'A3 Portrait'
63
+ }
64
+ });
65
+ this.mapContainer = map.getContainer();
66
+ this.originalState = {
67
+ mapWidth: this.mapContainer.style.width,
68
+ widthWasAuto: false,
69
+ widthWasPercentage: false,
70
+ mapHeight: this.mapContainer.style.height,
71
+ zoom: this._map.getZoom(),
72
+ center: this._map.getCenter()
73
+ };
74
+ }
75
+
76
+ _sizeModeObjs()
77
+ {
78
+ this.options.sizeModeObjs = this.options.sizeModes.map(function (sizeMode) {
79
+ if (sizeMode === 'Current') {
80
+ return {
81
+ name: this.options.defaultSizeTitles.Current,
82
+ className: 'CurrentSize'
83
+ }
84
+ }
85
+ if (sizeMode === 'A4Landscape') {
86
+ return {
87
+ height: this._a4PageSize.height,
88
+ width: this._a4PageSize.width,
89
+ name: this.options.defaultSizeTitles.A4Landscape,
90
+ className: 'A4Landscape page',
91
+ paperSize: 'A4'
92
+ }
93
+ }
94
+ if (sizeMode === 'A4Portrait') {
95
+ return {
96
+ height: this._a4PageSize.width,
97
+ width: this._a4PageSize.height,
98
+ name: this.options.defaultSizeTitles.A4Portrait,
99
+ className: 'A4Portrait page',
100
+ paperSize: 'A4'
101
+ }
102
+ };
103
+ if (sizeMode === 'A3Landscape') {
104
+ return {
105
+ height: this._a3PaperSize.height - this._pageMargin.y * 2,
106
+ width: this._a3PaperSize.width - this._pageMargin.x * 2,
107
+ name: this.options.defaultSizeTitles.A3Landscape,
108
+ className: 'A3Landscape page',
109
+ paperSize: 'A3'
110
+ }
111
+ }
112
+ if (sizeMode === 'A3Portrait') {
113
+ return {
114
+ height: this._a3PaperSize.width - this._pageMargin.x * 2,
115
+ width: this._a3PaperSize.height - this._pageMargin.y * 2,
116
+ name: this.options.defaultSizeTitles.A3Portrait,
117
+ className: 'A3Portrait page',
118
+ paperSize: 'A3'
119
+ }
120
+ };
121
+ return sizeMode;
122
+ }, this);
123
+ }
124
+ /**
125
+ * @param {string|{ target: { className: any; }; }} event
126
+ * @param {string} filename
127
+ */
128
+ printMap(event, filename) {
129
+ this.resolve = null;
130
+ this.reject = null;
131
+ this.format = "PNG";
132
+ if (filename) {
133
+ this.options.filename = filename
134
+ }
135
+ if (!this.options.exportOnly) {
136
+ this._page = window.open("", "_blank", 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10, top=10, width=200, height=250, visible=none');
137
+ this._page.document.write(this._createSpinner(this.options.customWindowTitle, this.options.customSpinnerClass, this.options.spinnerBgCOlor));
138
+ }
139
+ this._sizeModeObjs();
140
+ this.originalState = {
141
+ mapWidth: this.mapContainer.style.width,
142
+ widthWasAuto: false,
143
+ widthWasPercentage: false,
144
+ mapHeight: this.mapContainer.style.height,
145
+ zoom: this._map.getZoom(),
146
+ center: this._map.getCenter()
147
+ };
148
+ if (this.originalState.mapWidth === 'auto') {
149
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
150
+ this.originalState.widthWasAuto = true
151
+ } else if (this.originalState.mapWidth.includes('%')) {
152
+ this.originalState.percentageWidth = this.originalState.mapWidth
153
+ this.originalState.widthWasPercentage = true
154
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
155
+ }
156
+ this._map.fire("easyPrint-start", { event: event });
157
+ if (!this.options.hidden) {
158
+ this._togglePageSizeButtons({type: null});
159
+ }
160
+ if (this.options.hideControlContainer) {
161
+ this._toggleControls();
162
+ }
163
+ if (this.options.hideClasses) {
164
+ this._toggleClasses(this.options.hideClasses);
165
+ }
166
+ if (this.options.hideIds) {
167
+ this._toggleIds(this.options.hideIds);
168
+ }
169
+ let sizeMode = typeof event !== 'string' ? event.target.className : event;
170
+ if (sizeMode === 'CurrentSize') {
171
+ return this._printOpertion(sizeMode);
172
+ }
173
+ this.outerContainer = this._createOuterContainer(this.mapContainer)
174
+ if (this.originalState.widthWasAuto) {
175
+ this.outerContainer.style.width = this.originalState.mapWidth
176
+ }
177
+ this._createImagePlaceholder(sizeMode)
178
+ }
179
+
180
+ /**
181
+ * @param {math.Coord2D} size
182
+ * @returns {Promise<Blob>}
183
+ */
184
+ toPNG(size) {
185
+ this.resolve = null;
186
+ this.reject = null;
187
+ this.format = "PNG";
188
+ this._sizeModeObjs();
189
+ this.originalState = {
190
+ mapWidth: this.mapContainer.style.width,
191
+ widthWasAuto: false,
192
+ widthWasPercentage: false,
193
+ mapHeight: this.mapContainer.style.height,
194
+ zoom: this._map.getZoom(),
195
+ center: this._map.getCenter()
196
+ };
197
+ if (this.originalState.mapWidth === 'auto') {
198
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
199
+ this.originalState.widthWasAuto = true
200
+ } else if (this.originalState.mapWidth.includes('%')) {
201
+ this.originalState.percentageWidth = this.originalState.mapWidth
202
+ this.originalState.widthWasPercentage = true
203
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
204
+ }
205
+ let plugin = this;
206
+ return new Promise((resolve, reject) => {
207
+ plugin.resolve = resolve;
208
+ plugin.reject = reject;
209
+ if (!plugin.options.hidden) {
210
+ plugin._togglePageSizeButtons({type: null});
211
+ }
212
+ if (plugin.options.hideControlContainer) {
213
+ plugin._toggleControls();
214
+ }
215
+ if (plugin.options.hideClasses) {
216
+ plugin._toggleClasses(plugin.options.hideClasses);
217
+ }
218
+ if (plugin.options.hideIds) {
219
+ plugin._toggleIds(plugin.options.hideIds);
220
+ }
221
+ if (size == null) {
222
+ return plugin._printOpertion('CurrentSize');
223
+ }
224
+ plugin.outerContainer = plugin._createOuterContainer(plugin.mapContainer)
225
+ if (plugin.originalState.widthWasAuto) {
226
+ plugin.outerContainer.style.width = plugin.originalState.mapWidth
227
+ }
228
+ plugin._createImagePlaceholder(size)
229
+ });
230
+ }
231
+
232
+ /**
233
+ * @param {math.Coord2D} size
234
+ * @returns {Promise<Blob>}
235
+ */
236
+ toSVG(size) {
237
+ this.resolve = null;
238
+ this.reject = null;
239
+ this.format = "SVG";
240
+ this._sizeModeObjs();
241
+ this.originalState = {
242
+ mapWidth: this.mapContainer.style.width,
243
+ widthWasAuto: false,
244
+ widthWasPercentage: false,
245
+ mapHeight: this.mapContainer.style.height,
246
+ zoom: this._map.getZoom(),
247
+ center: this._map.getCenter()
248
+ };
249
+ if (this.originalState.mapWidth === 'auto') {
250
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
251
+ this.originalState.widthWasAuto = true
252
+ } else if (this.originalState.mapWidth.includes('%')) {
253
+ this.originalState.percentageWidth = this.originalState.mapWidth
254
+ this.originalState.widthWasPercentage = true
255
+ this.originalState.mapWidth = this._map.getSize().x + 'px'
256
+ }
257
+ let plugin = this;
258
+ return new Promise((resolve, reject) => {
259
+ plugin.resolve = resolve;
260
+ plugin.reject = reject;
261
+ if (!plugin.options.hidden) {
262
+ plugin._togglePageSizeButtons({type: null});
263
+ }
264
+ if (plugin.options.hideControlContainer) {
265
+ plugin._toggleControls();
266
+ }
267
+ if (plugin.options.hideClasses) {
268
+ plugin._toggleClasses(plugin.options.hideClasses);
269
+ }
270
+ if (plugin.options.hideIds) {
271
+ plugin._toggleIds(plugin.options.hideIds);
272
+ }
273
+ if (size == null) {
274
+ return plugin._printOpertion('CurrentSize');
275
+ }
276
+ plugin.outerContainer = plugin._createOuterContainer(plugin.mapContainer)
277
+ if (plugin.originalState.widthWasAuto) {
278
+ plugin.outerContainer.style.width = plugin.originalState.mapWidth
279
+ }
280
+ plugin._createImagePlaceholder(size)
281
+ });
282
+ }
283
+
284
+ /**
285
+ * @param {string} name
286
+ * @param {any} value
287
+ */
288
+ updateOptions(name, value) {
289
+ this.options[name] = value;
290
+ }
291
+
292
+ /**
293
+ * @param {string|math.Coord2D} sizeMode
294
+ */
295
+ async _createImagePlaceholder(sizeMode) {
296
+ let plugin = this;
297
+ let dataUrl = await domtoimage.toPng(this.mapContainer, {
298
+ width: parseInt(this.originalState.mapWidth.replace('px')),
299
+ height: parseInt(this.originalState.mapHeight.replace('px')),
300
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6AMECQMVtyBSbwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAALSURBVAjXY2AAAgAABQAB4iYFmwAAAABJRU5ErkJggg=="
301
+ });
302
+ try
303
+ {
304
+ plugin.blankDiv = document.createElement("div");
305
+ let blankDiv = plugin.blankDiv;
306
+ plugin.outerContainer.parentElement.insertBefore(blankDiv, plugin.outerContainer);
307
+ blankDiv.className = 'epHolder';
308
+ blankDiv.style.backgroundImage = 'url("' + dataUrl + '")';
309
+ blankDiv.style.position = 'absolute';
310
+ blankDiv.style.zIndex = 1011;
311
+ blankDiv.style.display = 'initial';
312
+ blankDiv.style.width = plugin.originalState.mapWidth;
313
+ blankDiv.style.height = plugin.originalState.mapHeight;
314
+ plugin._resizeAndPrintMap(sizeMode);
315
+ }
316
+ catch (error) {
317
+ console.error('oops, something went wrong!', error);
318
+ let dataUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6AMECQMVtyBSbwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAALSURBVAjXY2AAAgAABQAB4iYFmwAAAABJRU5ErkJggg==";
319
+ plugin.blankDiv = document.createElement("div");
320
+ let blankDiv = plugin.blankDiv;
321
+ plugin.outerContainer.parentElement.insertBefore(blankDiv, plugin.outerContainer);
322
+ blankDiv.className = 'epHolder';
323
+ blankDiv.style.backgroundImage = 'url("' + dataUrl + '")';
324
+ blankDiv.style.position = 'absolute';
325
+ blankDiv.style.zIndex = 1011;
326
+ blankDiv.style.display = 'initial';
327
+ blankDiv.style.width = plugin.originalState.mapWidth;
328
+ blankDiv.style.height = plugin.originalState.mapHeight;
329
+ plugin._resizeAndPrintMap(sizeMode);
330
+ }
331
+ }
332
+
333
+ /**
334
+ * @param {string|math.Coord2D} sizeMode
335
+ */
336
+ _resizeAndPrintMap(sizeMode) {
337
+ this.outerContainer.style.opacity = 0;
338
+ let pageSize;
339
+ if (typeof sizeMode == "string")
340
+ {
341
+ pageSize = this.options.sizeModeObjs.filter(function (item) {
342
+ return item.className.indexOf(sizeMode) > -1;
343
+ });
344
+ pageSize = pageSize[0];
345
+ }
346
+ else
347
+ {
348
+ pageSize = {width: sizeMode.x, height: sizeMode.y, className: "Custom", name: "Custom"};
349
+ }
350
+ if (pageSize == null)
351
+ {
352
+ console.log(this.options.sizeModeObjs, sizeMode);
353
+ throw new Error("sizeMode not found");
354
+ }
355
+ let pageBorderHeight = 0;
356
+ if (this.options.pageBorderHeight)
357
+ pageBorderHeight = this.options.pageBorderHeight + 4;
358
+ this.mapContainer.style.width = pageSize.width + 'px';
359
+ this.mapContainer.style.height = (pageSize.height - pageBorderHeight) + 'px';
360
+ if (pageSize.width < pageSize.height) {
361
+ this.orientation = web.PaperOrientation.Portrait;
362
+ } else {
363
+ this.orientation = web.PaperOrientation.Landscape;
364
+ }
365
+ this.paperSize = pageSize.paperSize;
366
+ this._map.setView(this.originalState.center);
367
+ this._map.setZoom(this.originalState.zoom);
368
+ this._map.invalidateSize();
369
+ if (this.options.tileLayer) {
370
+ this._pausePrint(sizeMode)
371
+ } else {
372
+ this._printOpertion(sizeMode)
373
+ }
374
+ }
375
+
376
+ /**
377
+ * @param {string|math.Coord2D} sizeMode
378
+ */
379
+ _pausePrint(sizeMode) {
380
+ let plugin = this;
381
+ let loadingTest = setInterval(function () {
382
+ let loading = false;
383
+ let tileLayer = plugin.options.tileLayer;
384
+ if (tileLayer.constructor === Array)
385
+ {
386
+ let i = 0;
387
+ let j = tileLayer.length;
388
+ while (i < j)
389
+ {
390
+ if (tileLayer[i].isLoading())
391
+ {
392
+ loading = true;
393
+ break;
394
+ }
395
+ i++;
396
+ }
397
+ }
398
+ else
399
+ {
400
+ loading = tileLayer.isLoading();
401
+ }
402
+ if (!loading)
403
+ {
404
+ clearInterval(loadingTest);
405
+ plugin._printOpertion(sizeMode)
406
+ }
407
+ }, plugin.options.tileWait);
408
+ }
409
+
410
+ /**
411
+ * @param {string|math.Coord2D} sizemode
412
+ */
413
+ async _printOpertion(sizemode) {
414
+ let plugin = this;
415
+ let widthForExport = this.mapContainer.style.width
416
+ if (this.originalState.widthWasAuto && sizemode === 'CurrentSize' || this.originalState.widthWasPercentage && sizemode === 'CurrentSize') {
417
+ widthForExport = this.originalState.mapWidth
418
+ }
419
+ let dataUrl;
420
+ if (this.format == "SVG")
421
+ {
422
+ dataUrl = await domtoimage.toSvg(plugin.mapContainer, {
423
+ width: parseInt(widthForExport),
424
+ height: parseInt(plugin.mapContainer.style.height.replace('px')),
425
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6AMECQMVtyBSbwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAALSURBVAjXY2AAAgAABQAB4iYFmwAAAABJRU5ErkJggg=="
426
+ });
427
+ }
428
+ else
429
+ {
430
+ dataUrl = await domtoimage.toPng(plugin.mapContainer, {
431
+ width: parseInt(widthForExport),
432
+ height: parseInt(plugin.mapContainer.style.height.replace('px')),
433
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH6AMECQMVtyBSbwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAALSURBVAjXY2AAAgAABQAB4iYFmwAAAABJRU5ErkJggg=="
434
+ });
435
+ }
436
+ try
437
+ {
438
+ let blob = data.dataURI2Blob(dataUrl);
439
+ if (plugin.resolve) {
440
+ plugin.resolve(blob);
441
+ } else if (plugin.options.exportOnly) {
442
+ web.openData(blob, blob.type, plugin.options.filename + '.png');
443
+ } else {
444
+ plugin._sendToBrowserPrint(dataUrl, plugin.orientation, plugin.paperSize);
445
+ }
446
+ plugin._toggleControls(true);
447
+ plugin._toggleClasses(plugin.options.hideClasses, true);
448
+ plugin._toggleIds(plugin.options.hideIds, true);
449
+
450
+ if (plugin.outerContainer) {
451
+ if (plugin.originalState.widthWasAuto) {
452
+ plugin.mapContainer.style.width = 'auto'
453
+ } else if (plugin.originalState.widthWasPercentage) {
454
+ plugin.mapContainer.style.width = plugin.originalState.percentageWidth
455
+ }
456
+ else {
457
+ plugin.mapContainer.style.width = plugin.originalState.mapWidth;
458
+ }
459
+ plugin.mapContainer.style.height = plugin.originalState.mapHeight;
460
+ plugin._removeOuterContainer(plugin.mapContainer, plugin.outerContainer, plugin.blankDiv)
461
+ plugin._map.invalidateSize();
462
+ plugin._map.setView(plugin.originalState.center);
463
+ plugin._map.setZoom(plugin.originalState.zoom);
464
+ }
465
+ plugin._map.fire("easyPrint-finished");
466
+ }
467
+ catch (error) {
468
+ console.error('Print operation failed', error);
469
+ if (plugin.reject)
470
+ {
471
+ plugin.reject("Failed");
472
+ }
473
+
474
+ plugin._page.document.close();
475
+ plugin._toggleControls(true);
476
+ plugin._toggleClasses(plugin.options.hideClasses, true);
477
+ plugin._toggleIds(plugin.options.hideIds, true);
478
+
479
+ if (plugin.outerContainer) {
480
+ if (plugin.originalState.widthWasAuto) {
481
+ plugin.mapContainer.style.width = 'auto'
482
+ } else if (plugin.originalState.widthWasPercentage) {
483
+ plugin.mapContainer.style.width = plugin.originalState.percentageWidth
484
+ }
485
+ else {
486
+ plugin.mapContainer.style.width = plugin.originalState.mapWidth;
487
+ }
488
+ plugin.mapContainer.style.height = plugin.originalState.mapHeight;
489
+ plugin._removeOuterContainer(plugin.mapContainer, plugin.outerContainer, plugin.blankDiv)
490
+ plugin._map.invalidateSize();
491
+ plugin._map.setView(plugin.originalState.center);
492
+ plugin._map.setZoom(plugin.originalState.zoom);
493
+ }
494
+ plugin._map.fire("easyPrint-finished");
495
+ }
496
+ }
497
+
498
+ /**
499
+ * @param {string} img
500
+ * @param {web.PaperOrientation} orientation
501
+ * @param {string | null} paperSize
502
+ */
503
+ _sendToBrowserPrint(img, orientation, paperSize) {
504
+ this._page.resizeTo(600, 800);
505
+ let pageContent = web.genPrintWindowHTML(img, orientation, paperSize, this.options);
506
+ this._page.document.body.innerHTML = ''
507
+ this._page.document.write(pageContent);
508
+ this._page.document.close();
509
+ }
510
+
511
+ /**
512
+ * @param {string} title
513
+ * @param {string} spinnerClass
514
+ * @param {string} spinnerColor
515
+ */
516
+ _createSpinner(title, spinnerClass, spinnerColor) {
517
+ return `<html><head><title>`+ title + `</title></head><body><style>
518
+ body{
519
+ background: ` + spinnerColor + `;
520
+ }
521
+ .epLoader,
522
+ .epLoader:before,
523
+ .epLoader:after {
524
+ border-radius: 50%;
525
+ }
526
+ .epLoader {
527
+ color: #ffffff;
528
+ font-size: 11px;
529
+ text-indent: -99999em;
530
+ margin: 55px auto;
531
+ position: relative;
532
+ width: 10em;
533
+ height: 10em;
534
+ box-shadow: inset 0 0 0 1em;
535
+ -webkit-transform: translateZ(0);
536
+ -ms-transform: translateZ(0);
537
+ transform: translateZ(0);
538
+ }
539
+ .epLoader:before,
540
+ .epLoader:after {
541
+ position: absolute;
542
+ content: '';
543
+ }
544
+ .epLoader:before {
545
+ width: 5.2em;
546
+ height: 10.2em;
547
+ background: #0dc5c1;
548
+ border-radius: 10.2em 0 0 10.2em;
549
+ top: -0.1em;
550
+ left: -0.1em;
551
+ -webkit-transform-origin: 5.2em 5.1em;
552
+ transform-origin: 5.2em 5.1em;
553
+ -webkit-animation: load2 2s infinite ease 1.5s;
554
+ animation: load2 2s infinite ease 1.5s;
555
+ }
556
+ .epLoader:after {
557
+ width: 5.2em;
558
+ height: 10.2em;
559
+ background: #0dc5c1;
560
+ border-radius: 0 10.2em 10.2em 0;
561
+ top: -0.1em;
562
+ left: 5.1em;
563
+ -webkit-transform-origin: 0px 5.1em;
564
+ transform-origin: 0px 5.1em;
565
+ -webkit-animation: load2 2s infinite ease;
566
+ animation: load2 2s infinite ease;
567
+ }
568
+ @-webkit-keyframes load2 {
569
+ 0% {
570
+ -webkit-transform: rotate(0deg);
571
+ transform: rotate(0deg);
572
+ }
573
+ 100% {
574
+ -webkit-transform: rotate(360deg);
575
+ transform: rotate(360deg);
576
+ }
577
+ }
578
+ @keyframes load2 {
579
+ 0% {
580
+ -webkit-transform: rotate(0deg);
581
+ transform: rotate(0deg);
582
+ }
583
+ 100% {
584
+ -webkit-transform: rotate(360deg);
585
+ transform: rotate(360deg);
586
+ }
587
+ }
588
+ </style>
589
+ <div class="`+spinnerClass+`">Loading...</div></body></html>`;
590
+ }
591
+
592
+ /**
593
+ * @param {HTMLDivElement} mapDiv
594
+ */
595
+ _createOuterContainer(mapDiv) {
596
+ let outerContainer = document.createElement('div');
597
+ mapDiv.parentNode.insertBefore(outerContainer, mapDiv);
598
+ mapDiv.parentNode.removeChild(mapDiv);
599
+ outerContainer.appendChild(mapDiv);
600
+ outerContainer.style.width = mapDiv.style.width;
601
+ outerContainer.style.height = mapDiv.style.height;
602
+ outerContainer.style.display = 'inline-block'
603
+ outerContainer.style.overflow = 'hidden';
604
+ return outerContainer;
605
+ }
606
+
607
+ /**
608
+ * @param {HTMLDivElement} mapDiv
609
+ * @param {HTMLDivElement} outerContainer
610
+ * @param {HTMLDivElement} blankDiv
611
+ */
612
+ _removeOuterContainer(mapDiv, outerContainer, blankDiv) {
613
+ if (outerContainer.parentNode) {
614
+ outerContainer.parentNode.insertBefore(mapDiv, outerContainer);
615
+ outerContainer.parentNode.removeChild(blankDiv);
616
+ outerContainer.parentNode.removeChild(outerContainer);
617
+ }
618
+ }
619
+
620
+ _addCss() {
621
+ let css = document.createElement("style");
622
+ css.type = "text/css";
623
+ css.innerHTML = `.leaflet-control-easyPrint-button {
624
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDUxMiA1MTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDUxMiA1MTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPGc+Cgk8cGF0aCBkPSJNMTI4LDMyaDI1NnY2NEgxMjhWMzJ6IE00ODAsMTI4SDMyYy0xNy42LDAtMzIsMTQuNC0zMiwzMnYxNjBjMCwxNy42LDE0LjM5OCwzMiwzMiwzMmg5NnYxMjhoMjU2VjM1Mmg5NiAgIGMxNy42LDAsMzItMTQuNCwzMi0zMlYxNjBDNTEyLDE0Mi40LDQ5Ny42LDEyOCw0ODAsMTI4eiBNMzUyLDQ0OEgxNjBWMjg4aDE5MlY0NDh6IE00ODcuMTk5LDE3NmMwLDEyLjgxMy0xMC4zODcsMjMuMi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LWJhY2tncm91bmQ6bmV3IDAgMCA0MzMuNSA0MzMuNTsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8Zz4KCTxnIGlkPSJmaWxlLWRvd25sb2FkIj4KCQk8cGF0aCBkPSJNMzk1LjI1LDE1M2gtMTAyVjBoLTE1M3YxNTNoLTEwMmwxNzguNSwxNzguNUwzOTUuMjUsMTUzeiBNMzguMjUsMzgyLjV2NTFoMzU3di01MUgzOC4yNXoiIGZpbGw9IiMwMDAwMDAiLz4KCTwvZz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);
630
+ background-size: 16px 16px;
631
+ cursor: pointer;
632
+ }
633
+ .easyPrintHolder a {
634
+ background-size: 16px 16px;
635
+ cursor: pointer;
636
+ }
637
+ .easyPrintHolder .CurrentSize{
638
+ background-image: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTZweCIgdmVyc2lvbj0iMS4xIiBoZWlnaHQ9IjE2cHgiIHZpZXdCb3g9IjAgMCA2NCA2NCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNjQgNjQi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N3YtMTA4LjhMMzcyLjU4MywxNDYuNDgzeiBNNzIuMjUsMzRoMTUwLjE2N3YxMzAuMzMzYzAsOS4zNSw3LjY1LDE3LDE3LDE3aDEzMy4xNjd2MjI5LjVINzIuMjVWMzR6ICAgICIgZmlsbD0iIzAwMDAwMCIvPgoJPC9nPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+Cjwvc3ZnPgo=);
642
+ }
643
+ .easyPrintHolder .A4Landscape {
644
+ transform: rotate(-90deg);
645
+ }
646
+ .easyPrintHolder .A3Landscape {
647
+ transform: rotate(-90deg);
648
+ }
649
+
650
+ .leaflet-control-easyPrint-button{
651
+ display: inline-block;
652
+ }
653
+ .easyPrintHolder{
654
+ margin-top:-31px;
655
+ margin-bottom: -5px;
656
+ margin-left: 30px;
657
+ padding-left: 0px;
658
+ display: none;
659
+ }
660
+
661
+ .easyPrintSizeMode {
662
+ display: inline-block;
663
+ }
664
+ .easyPrintHolder .easyPrintSizeMode a {
665
+ border-radius: 0px;
666
+ }
667
+
668
+ .easyPrintHolder .easyPrintSizeMode:last-child a{
669
+ border-top-right-radius: 2px;
670
+ border-bottom-right-radius: 2px;
671
+ margin-left: -1px;
672
+ }
673
+
674
+ .easyPrintPortrait:hover, .easyPrintLandscape:hover{
675
+ background-color: #757570;
676
+ cursor: pointer;
677
+ }`;
678
+ document.body.appendChild(css);
679
+ }
680
+
681
+ /**
682
+ * @param {{ type: any; }} e
683
+ */
684
+ _togglePageSizeButtons(e) {
685
+ /* let holderStyle = this.holder.style
686
+ let linkStyle = this.link.style
687
+ if (e.type === 'mouseover') {
688
+ holderStyle.display = 'block';
689
+ linkStyle.borderTopRightRadius = '0'
690
+ linkStyle.borderBottomRightRadius = '0'
691
+ } else {
692
+ holderStyle.display = 'none';
693
+ linkStyle.borderTopRightRadius = '2px'
694
+ linkStyle.borderBottomRightRadius = '2px'
695
+ }*/
696
+ }
697
+
698
+ /**
699
+ * @param {boolean | undefined} [show]
700
+ */
701
+ _toggleControls(show) {
702
+ let controlContainer = document.getElementsByClassName("leaflet-control-container")[0];
703
+ if (show)
704
+ controlContainer.style.display = 'block';
705
+ else
706
+ controlContainer.style.display = 'none';
707
+ }
708
+
709
+ /**
710
+ * @param {any[]} classes
711
+ * @param {boolean | undefined} [show]
712
+ */
713
+ _toggleClasses(classes, show) {
714
+ classes.forEach(function (/** @type {string} */ className) {
715
+ let divs = document.getElementsByClassName(className);
716
+ let i;
717
+ for (i in divs)
718
+ {
719
+ if (divs[i].style)
720
+ {
721
+ divs[i].style.display = show?'':'none';
722
+ }
723
+ }
724
+ });
725
+ }
726
+ /**
727
+ * @param {any[]} ids
728
+ * @param {boolean | undefined} [show]
729
+ */
730
+ _toggleIds(ids, show) {
731
+ ids.forEach(function (/** @type {string} */ id) {
732
+ let div = document.getElementById(id);
733
+ if (div && div.style)
734
+ {
735
+ div.style.display = show?'':'none';
736
+ }
737
+ });
738
+ }
739
+ }