@syncfusion/ej2-maps 30.2.4 → 31.2.2

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.
Files changed (61) hide show
  1. package/.eslintrc.json +263 -0
  2. package/dist/ej2-maps.min.js +2 -2
  3. package/dist/ej2-maps.umd.min.js +2 -2
  4. package/dist/global/ej2-maps.min.js +2 -2
  5. package/dist/global/index.d.ts +2 -2
  6. package/dist/ts/index.d.ts +4 -0
  7. package/dist/ts/index.ts +4 -0
  8. package/dist/ts/maps/index.d.ts +28 -0
  9. package/dist/ts/maps/index.ts +28 -0
  10. package/dist/ts/maps/layers/bing-map.d.ts +21 -0
  11. package/dist/ts/maps/layers/bing-map.ts +51 -0
  12. package/dist/ts/maps/layers/bubble.d.ts +77 -0
  13. package/dist/ts/maps/layers/bubble.ts +304 -0
  14. package/dist/ts/maps/layers/color-mapping.d.ts +36 -0
  15. package/dist/ts/maps/layers/color-mapping.ts +230 -0
  16. package/dist/ts/maps/layers/data-label.d.ts +45 -0
  17. package/dist/ts/maps/layers/data-label.ts +457 -0
  18. package/dist/ts/maps/layers/layer-panel.d.ts +144 -0
  19. package/dist/ts/maps/layers/layer-panel.ts +1455 -0
  20. package/dist/ts/maps/layers/legend.d.ts +173 -0
  21. package/dist/ts/maps/layers/legend.ts +2465 -0
  22. package/dist/ts/maps/layers/marker.d.ts +105 -0
  23. package/dist/ts/maps/layers/marker.ts +632 -0
  24. package/dist/ts/maps/layers/navigation-selected-line.d.ts +33 -0
  25. package/dist/ts/maps/layers/navigation-selected-line.ts +171 -0
  26. package/dist/ts/maps/layers/polygon.d.ts +30 -0
  27. package/dist/ts/maps/layers/polygon.ts +68 -0
  28. package/dist/ts/maps/maps-model.d.ts +409 -0
  29. package/dist/ts/maps/maps.d.ts +1247 -0
  30. package/dist/ts/maps/maps.ts +3416 -0
  31. package/dist/ts/maps/model/base-model.d.ts +2107 -0
  32. package/dist/ts/maps/model/base.d.ts +1840 -0
  33. package/dist/ts/maps/model/base.ts +2257 -0
  34. package/dist/ts/maps/model/constants.d.ts +225 -0
  35. package/dist/ts/maps/model/constants.ts +226 -0
  36. package/dist/ts/maps/model/export-image.d.ts +39 -0
  37. package/dist/ts/maps/model/export-image.ts +194 -0
  38. package/dist/ts/maps/model/export-pdf.d.ts +40 -0
  39. package/dist/ts/maps/model/export-pdf.ts +183 -0
  40. package/dist/ts/maps/model/interface.d.ts +892 -0
  41. package/dist/ts/maps/model/interface.ts +929 -0
  42. package/dist/ts/maps/model/print.d.ts +45 -0
  43. package/dist/ts/maps/model/print.ts +125 -0
  44. package/dist/ts/maps/model/theme.d.ts +98 -0
  45. package/dist/ts/maps/model/theme.ts +919 -0
  46. package/dist/ts/maps/user-interaction/annotation.d.ts +27 -0
  47. package/dist/ts/maps/user-interaction/annotation.ts +133 -0
  48. package/dist/ts/maps/user-interaction/highlight.d.ts +63 -0
  49. package/dist/ts/maps/user-interaction/highlight.ts +272 -0
  50. package/dist/ts/maps/user-interaction/selection.d.ts +85 -0
  51. package/dist/ts/maps/user-interaction/selection.ts +342 -0
  52. package/dist/ts/maps/user-interaction/tooltip.d.ts +78 -0
  53. package/dist/ts/maps/user-interaction/tooltip.ts +500 -0
  54. package/dist/ts/maps/user-interaction/zoom.d.ts +334 -0
  55. package/dist/ts/maps/user-interaction/zoom.ts +2523 -0
  56. package/dist/ts/maps/utils/enum.d.ts +328 -0
  57. package/dist/ts/maps/utils/enum.ts +343 -0
  58. package/dist/ts/maps/utils/helper.d.ts +1318 -0
  59. package/dist/ts/maps/utils/helper.ts +3811 -0
  60. package/package.json +53 -18
  61. package/tslint.json +111 -0
@@ -0,0 +1,40 @@
1
+ import { Maps } from '../../index';
2
+ import { ExportType } from '../utils/enum';
3
+ import { PdfPageOrientation } from '@syncfusion/ej2-pdf-export';
4
+ /**
5
+ * This module enables the export to PDF functionality in maps.
6
+ *
7
+ * @hidden
8
+ */
9
+ export declare class PdfExport {
10
+ /**
11
+ * Constructor for Maps
12
+ *
13
+ */
14
+ constructor();
15
+ /**
16
+ * To export the file as image/svg format
17
+ *
18
+ * @param {Maps} maps - Specifies the Maps instance.
19
+ * @param {ExportType} type - Specifies the type of the document.
20
+ * @param {string} fileName - Specifies the name of the PDF document.
21
+ * @param {boolean} allowDownload - Specifies whether to download the document or not.
22
+ * @param {PdfPageOrientation} orientation - Specifies the orientation of the PDF document to export the maps.
23
+ * @returns {Promise<string>} - Returns "null" value when the allowDownload is set to false.
24
+ * @private
25
+ */
26
+ export(maps: Maps, type: ExportType, fileName: string, allowDownload?: boolean, orientation?: PdfPageOrientation): Promise<string>;
27
+ /**
28
+ * Get module name.
29
+ *
30
+ * @returns {string} - Returns the module name
31
+ */
32
+ protected getModuleName(): string;
33
+ /**
34
+ * To destroy the PdfExport.
35
+ *
36
+ * @returns {void}
37
+ * @private
38
+ */
39
+ destroy(): void;
40
+ }
@@ -0,0 +1,183 @@
1
+ import { createElement, isNullOrUndefined} from '@syncfusion/ej2-base';
2
+ import { Maps } from '../../index';
3
+ import { ExportType } from '../utils/enum';
4
+ import { PdfPageOrientation, PdfDocument, PdfBitmap } from '@syncfusion/ej2-pdf-export';
5
+
6
+
7
+ /**
8
+ * This module enables the export to PDF functionality in maps.
9
+ *
10
+ * @hidden
11
+ */
12
+ export class PdfExport {
13
+
14
+ /**
15
+ * Constructor for Maps
16
+ *
17
+ */
18
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
19
+ constructor() { }
20
+
21
+ /**
22
+ * To export the file as image/svg format
23
+ *
24
+ * @param {Maps} maps - Specifies the Maps instance.
25
+ * @param {ExportType} type - Specifies the type of the document.
26
+ * @param {string} fileName - Specifies the name of the PDF document.
27
+ * @param {boolean} allowDownload - Specifies whether to download the document or not.
28
+ * @param {PdfPageOrientation} orientation - Specifies the orientation of the PDF document to export the maps.
29
+ * @returns {Promise<string>} - Returns "null" value when the allowDownload is set to false.
30
+ * @private
31
+ */
32
+ public export(maps: Maps, type: ExportType, fileName: string, allowDownload?: boolean,
33
+ orientation?: PdfPageOrientation): Promise<string> {
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ const promise: Promise<string> = new Promise((resolve: any) => {
36
+ if (maps.isTileMap) {
37
+ maps.isExportInitialTileMap = true;
38
+ }
39
+ const canvasElement: HTMLCanvasElement = <HTMLCanvasElement>createElement('canvas', {
40
+ id: 'ej2-canvas',
41
+ attrs: {
42
+ 'width': maps.availableSize.width.toString(),
43
+ 'height': maps.availableSize.height.toString()
44
+ }
45
+ });
46
+ orientation = isNullOrUndefined(orientation) ? PdfPageOrientation.Landscape : orientation;
47
+ const svgParent: HTMLElement = document.getElementById(maps.element.id + '_Tile_SVG_Parent');
48
+ let svgData: string;
49
+ const exportElement: HTMLElement = maps.svgObject.cloneNode(true) as HTMLElement;
50
+ const backgroundElement: HTMLElement = exportElement.childNodes[0] as HTMLElement;
51
+ const backgroundColor: string = backgroundElement.getAttribute('fill');
52
+ if ((maps.theme === 'Tailwind' || maps.theme === 'Tailwind3' || maps.theme === 'Bootstrap5' || maps.theme === 'Fluent' || maps.theme === 'Material3' ||
53
+ maps.theme === 'Fluent2')
54
+ && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
55
+ (exportElement.childNodes[0] as HTMLElement).setAttribute('fill', 'rgba(255,255,255, 1)');
56
+ } else if ((maps.theme === 'TailwindDark' || maps.theme === 'Tailwind3Dark' || maps.theme === 'Bootstrap5Dark' || maps.theme === 'FluentDark' || maps.theme === 'Material3Dark' ||
57
+ maps.theme === 'Fluent2Dark' || maps.theme === 'Fluent2HighContrast')
58
+ && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) {
59
+ (exportElement.childNodes[0] as HTMLElement).setAttribute('fill', 'rgba(0, 0, 0, 1)');
60
+ }
61
+ const url: string = window.URL.createObjectURL(
62
+ new Blob(
63
+ type === 'SVG' ? [svgData] :
64
+ [(new XMLSerializer()).serializeToString(exportElement)],
65
+ { type: 'image/svg+xml' }
66
+ )
67
+ );
68
+ const pdfDocument: PdfDocument = new PdfDocument();
69
+ const image: HTMLImageElement = new Image();
70
+ const ctx: CanvasRenderingContext2D = canvasElement.getContext('2d');
71
+ if (!maps.isTileMap) {
72
+ image.onload = (() => {
73
+ ctx.drawImage(image, 0, 0);
74
+ window.URL.revokeObjectURL(url);
75
+ if (type === 'PDF') {
76
+ let imageString: string = canvasElement.toDataURL('image/jpeg').replace('image/jpeg', 'image/octet-stream');
77
+ pdfDocument.pageSettings.orientation = orientation;
78
+ imageString = imageString.slice(imageString.indexOf(',') + 1);
79
+ pdfDocument.pages.add().graphics.drawImage(
80
+ new PdfBitmap(imageString), 0, 0, (maps.availableSize.width - 60), maps.availableSize.height
81
+ );
82
+ if (allowDownload) {
83
+ pdfDocument.save(fileName + '.pdf');
84
+ pdfDocument.destroy();
85
+ } else {
86
+ resolve(null);
87
+ }
88
+ }
89
+ });
90
+ image.src = url;
91
+ } else {
92
+ const svgParentElement: HTMLElement = document.getElementById(maps.element.id + '_MapAreaBorder');
93
+ const top: number = parseFloat(svgParentElement.getAttribute('y'));
94
+ const left: number = parseFloat(svgParentElement.getAttribute('x'));
95
+ const xHttp: XMLHttpRequest = new XMLHttpRequest();
96
+ const tileLength: number = maps.mapLayerPanel.tiles.length;
97
+ for (let i: number = 0; i <= tileLength + 1; i++) {
98
+ const tile: HTMLElement = document.getElementById(maps.element.id + '_tile_' + (i - 1));
99
+ const tileImg: HTMLImageElement = new Image();
100
+ tileImg.crossOrigin = 'Anonymous';
101
+ const background: string = maps.background ? maps.background : ((maps.theme === 'Tailwind' || maps.theme === 'Tailwind3' || maps.theme === 'Bootstrap5' || maps.theme === 'Fluent' || maps.theme === 'Material3') && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent')) ? '#ffffff' :
102
+ (maps.theme === 'TailwindDark' || maps.theme === 'Tailwind3Dark' || maps.theme === 'Bootstrap5Dark' || maps.theme === 'FluentDark' || maps.theme === 'Material3Dark') && (backgroundColor === 'rgba(255,255,255, 0.0)' || backgroundColor === 'transparent') ? '#000000' : '#ffffff';
103
+ ctx.fillStyle = background;
104
+ ctx.fillRect(0, 0, maps.availableSize.width, maps.availableSize.height);
105
+ ctx.font = maps.titleSettings.textStyle.size + ' Arial';
106
+ const titleElement: HTMLElement = document.getElementById(maps.element.id + '_Map_title');
107
+ if (!isNullOrUndefined(titleElement)) {
108
+ ctx.fillStyle = titleElement.getAttribute('fill');
109
+ ctx.fillText(
110
+ maps.titleSettings.text, parseFloat(titleElement.getAttribute('x')),
111
+ parseFloat(titleElement.getAttribute('y')));
112
+ }
113
+ tileImg.onload = (() => {
114
+ if (i === 0 || i === tileLength + 1) {
115
+ if (i === 0) {
116
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
117
+ ctx.rect(0, top, parseFloat(svgParent.style.width), parseFloat(svgParent.style.height));
118
+ ctx.clip();
119
+ } else {
120
+ ctx.setTransform(1, 0, 0, 1, left, top);
121
+ }
122
+ } else {
123
+ ctx.setTransform(1, 0, 0, 1, parseFloat(tile.style.left) + left, parseFloat(tile.style.top) + top);
124
+ }
125
+ ctx.drawImage(tileImg, 0, 0);
126
+ if (i === tileLength + 1) {
127
+ if (type === 'PDF') {
128
+ localStorage.setItem('saved-image-example', canvasElement.toDataURL('image/jpeg'));
129
+ let x: string = localStorage.getItem('saved-image-example');
130
+ pdfDocument.pageSettings.orientation = orientation;
131
+ x = x.slice(x.indexOf(',') + 1);
132
+ pdfDocument.pages.add().graphics.drawImage(
133
+ new PdfBitmap(x), 0, 0, (maps.availableSize.width - 60), maps.availableSize.height
134
+ );
135
+ maps.isExportInitialTileMap = false;
136
+ if (allowDownload) {
137
+ pdfDocument.save(fileName + '.pdf');
138
+ pdfDocument.destroy();
139
+ } else {
140
+ resolve(null);
141
+ }
142
+ }
143
+ }
144
+ });
145
+ if (i === 0 || i === tileLength + 1) {
146
+ if (i === 0) {
147
+ tileImg.src = url;
148
+ } else {
149
+ setTimeout(() => {
150
+ const tileSvg: Element = document.getElementById(maps.element.id + '_Tile_SVG');
151
+ tileImg.src = window.URL.createObjectURL(new Blob(
152
+ [(new XMLSerializer()).serializeToString(tileSvg)],
153
+ { type: 'image/svg+xml' }));
154
+ }, 300);
155
+ }
156
+ } else {
157
+ xHttp.open('GET', tile.children[0].getAttribute('src'), true);
158
+ xHttp.send();
159
+ tileImg.src = tile.children[0].getAttribute('src');
160
+ }
161
+ }
162
+ }
163
+ });
164
+ return promise;
165
+ }
166
+ /**
167
+ * Get module name.
168
+ *
169
+ * @returns {string} - Returns the module name
170
+ */
171
+ protected getModuleName(): string {
172
+ return 'PdfExport';
173
+ }
174
+
175
+ /**
176
+ * To destroy the PdfExport.
177
+ *
178
+ * @returns {void}
179
+ * @private
180
+ */
181
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
182
+ public destroy(): void { }
183
+ }