@syncfusion/ej2-maps 19.4.53 → 19.4.56-105067

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 (84) hide show
  1. package/.eslintrc.json +18 -3
  2. package/.github/PULL_REQUEST_TEMPLATE/Bug.md +72 -72
  3. package/.github/PULL_REQUEST_TEMPLATE/Feature.md +49 -49
  4. package/CHANGELOG.md +441 -422
  5. package/README.md +73 -73
  6. package/dist/ej2-maps.umd.min.js +1 -10
  7. package/dist/ej2-maps.umd.min.js.map +1 -1
  8. package/dist/es6/ej2-maps.es2015.js +1220 -653
  9. package/dist/es6/ej2-maps.es2015.js.map +1 -1
  10. package/dist/es6/ej2-maps.es5.js +1258 -692
  11. package/dist/es6/ej2-maps.es5.js.map +1 -1
  12. package/dist/global/ej2-maps.min.js +1 -10
  13. package/dist/global/ej2-maps.min.js.map +1 -1
  14. package/dist/global/index.d.ts +0 -9
  15. package/dist/ts/maps/layers/bing-map.ts +50 -0
  16. package/dist/ts/maps/layers/bubble.ts +290 -0
  17. package/dist/ts/maps/layers/color-mapping.ts +226 -0
  18. package/dist/ts/maps/layers/data-label.ts +418 -0
  19. package/dist/ts/maps/layers/layer-panel.ts +1480 -0
  20. package/dist/ts/maps/layers/legend.ts +2236 -0
  21. package/dist/ts/maps/layers/marker.ts +453 -0
  22. package/dist/ts/maps/layers/navigation-selected-line.ts +167 -0
  23. package/dist/ts/maps/maps.ts +2886 -0
  24. package/dist/ts/maps/model/base.ts +1843 -0
  25. package/dist/ts/maps/model/constants.ts +200 -0
  26. package/dist/ts/maps/model/export-image.ts +178 -0
  27. package/dist/ts/maps/model/export-pdf.ts +170 -0
  28. package/dist/ts/maps/model/interface.ts +823 -0
  29. package/dist/ts/maps/model/print.ts +104 -0
  30. package/dist/ts/maps/model/theme.ts +554 -0
  31. package/dist/ts/maps/user-interaction/annotation.ts +127 -0
  32. package/dist/ts/maps/user-interaction/highlight.ts +233 -0
  33. package/dist/ts/maps/user-interaction/selection.ts +321 -0
  34. package/dist/ts/maps/user-interaction/tooltip.ts +387 -0
  35. package/dist/ts/maps/user-interaction/zoom.ts +1767 -0
  36. package/dist/ts/maps/utils/enum.ts +368 -0
  37. package/dist/ts/maps/utils/helper.ts +3421 -0
  38. package/helper/e2e/index.js +3 -3
  39. package/helper/e2e/maps-helper.js +13 -13
  40. package/license +9 -9
  41. package/package.json +85 -85
  42. package/src/maps/layers/bing-map.d.ts +4 -0
  43. package/src/maps/layers/bing-map.js +16 -3
  44. package/src/maps/layers/bubble.d.ts +1 -2
  45. package/src/maps/layers/bubble.js +7 -12
  46. package/src/maps/layers/data-label.d.ts +1 -4
  47. package/src/maps/layers/data-label.js +32 -35
  48. package/src/maps/layers/layer-panel.d.ts +18 -1
  49. package/src/maps/layers/layer-panel.js +226 -72
  50. package/src/maps/layers/legend.d.ts +5 -2
  51. package/src/maps/layers/legend.js +170 -61
  52. package/src/maps/layers/marker.d.ts +2 -4
  53. package/src/maps/layers/marker.js +49 -48
  54. package/src/maps/layers/navigation-selected-line.d.ts +1 -2
  55. package/src/maps/layers/navigation-selected-line.js +7 -13
  56. package/src/maps/maps-model.d.ts +259 -251
  57. package/src/maps/maps.d.ts +25 -3
  58. package/src/maps/maps.js +179 -106
  59. package/src/maps/model/base-model.d.ts +1025 -1021
  60. package/src/maps/model/base.d.ts +5 -1
  61. package/src/maps/model/base.js +24 -24
  62. package/src/maps/model/constants.d.ts +6 -0
  63. package/src/maps/model/constants.js +6 -0
  64. package/src/maps/model/export-image.d.ts +2 -4
  65. package/src/maps/model/export-image.js +34 -33
  66. package/src/maps/model/export-pdf.d.ts +4 -6
  67. package/src/maps/model/export-pdf.js +31 -32
  68. package/src/maps/model/interface.d.ts +34 -26
  69. package/src/maps/model/print.d.ts +2 -5
  70. package/src/maps/model/print.js +32 -18
  71. package/src/maps/model/theme.js +7 -4
  72. package/src/maps/user-interaction/annotation.d.ts +1 -2
  73. package/src/maps/user-interaction/annotation.js +3 -4
  74. package/src/maps/user-interaction/highlight.d.ts +1 -2
  75. package/src/maps/user-interaction/highlight.js +11 -10
  76. package/src/maps/user-interaction/selection.d.ts +1 -2
  77. package/src/maps/user-interaction/selection.js +42 -19
  78. package/src/maps/user-interaction/tooltip.d.ts +3 -5
  79. package/src/maps/user-interaction/tooltip.js +27 -14
  80. package/src/maps/user-interaction/zoom.d.ts +3 -8
  81. package/src/maps/user-interaction/zoom.js +282 -162
  82. package/src/maps/utils/enum.d.ts +5 -1
  83. package/src/maps/utils/helper.d.ts +9 -1
  84. package/src/maps/utils/helper.js +82 -33
@@ -0,0 +1,1480 @@
1
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
+ /* eslint-disable jsdoc/require-param */
3
+ /* eslint-disable no-case-declarations */
4
+ /* eslint-disable @typescript-eslint/no-unused-vars */
5
+ import { isNullOrUndefined, extend, createElement, Ajax } from '@syncfusion/ej2-base';
6
+ import { Maps } from '../../maps/maps';
7
+ import { getShapeColor } from '../model/theme';
8
+ import { GeoLocation, isCustomPath, convertGeoToPoint, Point, PathOption, Size, PolylineOption, removeElement } from '../utils/helper';
9
+ import { getElementByID, maintainSelection, getValueFromObject } from '../utils/helper';
10
+ import { MapLocation, RectOption, getTranslate, convertTileLatLongToPoint, checkShapeDataFields, CircleOption } from '../utils/helper';
11
+ import { getZoomTranslate, fixInitialScaleForTile } from '../utils/helper';
12
+ import { LayerSettings, ShapeSettings, Tile, BubbleSettings } from '../model/base';
13
+ import { BorderModel, LayerSettingsModel, ShapeSettingsModel, ToggleLegendSettingsModel } from '../model/base-model';
14
+ import { BingMap } from './bing-map';
15
+ import { ColorMapping } from './color-mapping';
16
+ import { layerRendering, ILayerRenderingEventArgs, shapeRendering, IShapeRenderingEventArgs, BubbleSettingsModel, Rect } from '../index';
17
+ /**
18
+ * To calculate and render the shape layer
19
+ */
20
+
21
+ export class LayerPanel {
22
+ private mapObject: Maps;
23
+ public currentFactor: number;
24
+ private groupElements: Element[];
25
+ private layerObject: Element;
26
+ private currentLayer: LayerSettings;
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ private rectBounds: any;
29
+ public tiles: Tile[];
30
+ private clipRectElement: Element;
31
+ private urlTemplate: string;
32
+ private isMapCoordinates: boolean = true;
33
+ private tileSvgObject: Element;
34
+ private ajaxModule: Ajax;
35
+ private ajaxResponse: LayerSettings[];
36
+ private bing: BingMap;
37
+ private animateToZoomX : number;
38
+ private animateToZoomY : number;
39
+ public horizontalPan: boolean = false;
40
+ public horizontalPanXCount: number = 0;
41
+ public layerGroup: Element;
42
+ constructor(map: Maps) {
43
+ this.mapObject = map;
44
+ this.ajaxModule = new Ajax();
45
+ this.ajaxResponse = [];
46
+ }
47
+
48
+ public measureLayerPanel(): void {
49
+ const layerCollection: LayerSettings[] = <LayerSettings[]>this.mapObject.layersCollection;
50
+ const areaRect: Rect = this.mapObject.mapAreaRect;
51
+ const secondaryEle: HTMLElement = <HTMLElement>getElementByID(this.mapObject.element.id + '_Secondary_Element');
52
+ if (this.mapObject.isTileMap && secondaryEle) {
53
+ this.tileSvgObject = this.mapObject.renderer.createSvg({
54
+ id: this.mapObject.element.id + '_Tile_SVG', width: areaRect.width,
55
+ height: areaRect.height
56
+ });
57
+ const parentElement: Element = createElement('div', {
58
+ id: this.mapObject.element.id + '_Tile_SVG_Parent', styles: 'position: absolute; height: ' +
59
+ (areaRect.height) + 'px; width: '
60
+ + (areaRect.width) + 'px;'
61
+ });
62
+ parentElement.appendChild(this.tileSvgObject);
63
+ secondaryEle.appendChild(parentElement);
64
+ }
65
+ this.layerGroup = (this.mapObject.renderer.createGroup({
66
+ id: this.mapObject.element.id + '_Layer_Collections',
67
+ 'clip-path': 'url(#' + this.mapObject.element.id + '_MapArea_ClipRect)'
68
+ }));
69
+ if (this.mapObject.layers[this.mapObject.baseLayerIndex].layerType === 'GoogleStaticMap') {
70
+ const staticMapSize : number = 640;
71
+ this.clipRectElement = this.mapObject.renderer.drawClipPath(new RectOption(
72
+ this.mapObject.element.id + '_MapArea_ClipRect',
73
+ 'transparent', { width: 1, color: 'Gray' }, 1,
74
+ {
75
+ x: ((areaRect.width - staticMapSize) / 2), y: 0,
76
+ width: staticMapSize, height: areaRect.height
77
+ }));
78
+ } else {
79
+ this.clipRectElement = this.mapObject.renderer.drawClipPath(new RectOption(
80
+ this.mapObject.element.id + '_MapArea_ClipRect',
81
+ 'transparent', { width: 1, color: 'Gray' }, 1,
82
+ {
83
+ x: this.mapObject.isTileMap ? 0 : areaRect.x, y: this.mapObject.isTileMap ? 0 : areaRect.y,
84
+ width: areaRect.width, height: areaRect.height
85
+ }));
86
+ }
87
+
88
+ this.layerGroup.appendChild(this.clipRectElement);
89
+ this.mapObject.baseMapBounds = null;
90
+ this.mapObject.baseMapRectBounds = null;
91
+ this.mapObject.baseSize = null;
92
+ Array.prototype.forEach.call(layerCollection, (layer: LayerSettings, index: number) => {
93
+ this.currentLayer = <LayerSettings>layer;
94
+ this.processLayers(layer, index);
95
+ });
96
+ if (!isNullOrUndefined(this.mapObject.legendModule) && this.mapObject.legendSettings.position === 'Float') {
97
+ if (this.mapObject.isTileMap) {
98
+ this.layerGroup.appendChild(this.mapObject.legendModule.legendGroup);
99
+ } else {
100
+ this.mapObject.svgObject.appendChild(this.mapObject.legendModule.legendGroup);
101
+ }
102
+ }
103
+ }
104
+ /**
105
+ * Tile rendering
106
+ *
107
+ * @param {LayerPanel} panel - Specifies the layer panel.
108
+ * @param {LayerSettings} layer - Specifies the layer settings.
109
+ * @param {number} layerIndex - Specifies the layer index.
110
+ * @param {BingMap} bing - Specifies the bing map.
111
+ * @returns {void}
112
+ * @private
113
+ */
114
+ public renderTileLayer(panel: LayerPanel, layer: LayerSettings, layerIndex: number, bing?: BingMap): void {
115
+ panel.currentFactor = panel.calculateFactor(layer);
116
+ panel.mapObject.defaultState = ((panel.mapObject.zoomSettings.zoomFactor !== 1) &&
117
+ (!isNullOrUndefined(panel.mapObject.tileZoomLevel) && panel.mapObject.tileZoomLevel !== 1 )) ?
118
+ false : true;
119
+ if (isNullOrUndefined(panel.mapObject.previousCenterLatitude) &&
120
+ isNullOrUndefined(panel.mapObject.previousCenterLongitude)) {
121
+ panel.mapObject.previousCenterLatitude = panel.mapObject.centerPosition.latitude;
122
+ panel.mapObject.previousCenterLongitude = panel.mapObject.centerPosition.longitude;
123
+ } else if (panel.mapObject.previousCenterLatitude !==
124
+ panel.mapObject.centerPosition.latitude && panel.mapObject.previousCenterLongitude !==
125
+ panel.mapObject.centerPosition.longitude) {
126
+ panel.mapObject.centerPositionChanged = true;
127
+ panel.mapObject.previousCenterLatitude = panel.mapObject.centerPosition.latitude;
128
+ panel.mapObject.previousCenterLongitude = panel.mapObject.centerPosition.longitude;
129
+ } else {
130
+ panel.mapObject.centerPositionChanged = false;
131
+ }
132
+ let center: Point = new Point(panel.mapObject.centerPosition.longitude, panel.mapObject.centerPosition.latitude);
133
+ let centerTileMap : Point = center;
134
+ if ((this.mapObject.isTileMap && panel.mapObject.markerModule) && panel.mapObject.zoomSettings.enable) {
135
+ panel.mapObject.markerModule.calculateZoomCenterPositionAndFactor(this.mapObject.layersCollection);
136
+ if (!isNullOrUndefined(this.mapObject.markerCenterLatitude) && !isNullOrUndefined(this.mapObject.markerCenterLongitude)) {
137
+ centerTileMap = new Point(panel.mapObject.markerCenterLongitude, panel.mapObject.markerCenterLatitude);
138
+ }
139
+ }
140
+ if (!panel.mapObject.zoomSettings.shouldZoomInitially && panel.mapObject.centerPosition.longitude
141
+ && panel.mapObject.centerPosition.latitude && !panel.mapObject.zoomPersistence && panel.mapObject.defaultState) {
142
+ center = new Point(panel.mapObject.centerPosition.longitude, panel.mapObject.centerPosition.latitude);
143
+ } else if (panel.mapObject.zoomSettings.shouldZoomInitially
144
+ && panel.mapObject.markerZoomedState && !panel.mapObject.zoomPersistence
145
+ && !isNullOrUndefined(panel.mapObject.markerZoomCenterPoint)) {
146
+ center = new Point(panel.mapObject.markerZoomCenterPoint.longitude, panel.mapObject.markerZoomCenterPoint.latitude);
147
+ } else {
148
+ center = { x: null, y: null };
149
+ }
150
+ let zoomFactorValue: number = panel.mapObject.zoomSettings.shouldZoomInitially ?
151
+ isNullOrUndefined(panel.mapObject.markerZoomFactor) ? 1 :
152
+ panel.mapObject.markerZoomFactor : panel.mapObject.zoomSettings.zoomFactor;
153
+ zoomFactorValue = (panel.mapObject.enablePersistence) ? ((isNullOrUndefined(panel.mapObject.mapScaleValue))
154
+ ? (isNullOrUndefined(panel.mapObject.markerZoomFactor) ? panel.mapObject.zoomSettings.zoomFactor :
155
+ panel.mapObject.markerZoomFactor) : panel.mapObject.mapScaleValue) : zoomFactorValue;
156
+ zoomFactorValue = panel.mapObject.zoomSettings.enable ? zoomFactorValue : panel.mapObject.zoomSettings.zoomFactor;
157
+ zoomFactorValue = zoomFactorValue > 0 ? zoomFactorValue : 1;
158
+ panel.mapObject.defaultState = zoomFactorValue !== 1 ? false : true;
159
+ if (!panel.mapObject.markerZoomedState && panel.mapObject.zoomSettings.shouldZoomInitially &&
160
+ panel.mapObject.zoomSettings.zoomFactor === 1) {
161
+ panel.mapObject.defaultState = true;
162
+ }
163
+ if (isNullOrUndefined(panel.mapObject.tileZoomLevel)) {
164
+ panel.mapObject.tileZoomLevel = zoomFactorValue;
165
+ panel.mapObject.previousZoomFactor = zoomFactorValue;
166
+ } else if (this.mapObject.isReset && panel.mapObject.tileZoomLevel === 1 && !panel.mapObject.zoomSettings.shouldZoomInitially) {
167
+ const zoomLevel: number = panel.mapObject.tileZoomLevel;
168
+ panel.mapObject.tileZoomLevel = zoomLevel;
169
+ } else if (panel.mapObject.zoomSettings.zoomFactor !== 1 || panel.mapObject.zoomSettings.shouldZoomInitially) {
170
+ panel.mapObject.previousZoomFactor = panel.mapObject.tileZoomLevel;
171
+ panel.mapObject.tileZoomLevel = panel.mapObject.defaultState && panel.mapObject.zoomSettings.enable ?
172
+ panel.mapObject.tileZoomLevel : !panel.mapObject.zoomSettings.shouldZoomInitially
173
+ && !panel.mapObject.centerPositionChanged ?
174
+ panel.mapObject.previousZoomFactor !== panel.mapObject.zoomSettings.zoomFactor ?
175
+ panel.mapObject.zoomSettings.zoomFactor : panel.mapObject.tileZoomLevel : zoomFactorValue;
176
+ panel.mapObject.tileZoomLevel = zoomFactorValue === 1 && panel.mapObject.zoomSettings.zoomFactor === 0 ?
177
+ zoomFactorValue : panel.mapObject.tileZoomLevel;
178
+ if (!isNullOrUndefined(panel.mapObject.tileTranslatePoint) &&
179
+ (panel.mapObject.markerZoomFactor !== panel.mapObject.mapScaleValue
180
+ || (isNullOrUndefined(panel.mapObject.markerZoomFactor)
181
+ && isNullOrUndefined(panel.mapObject.mapScaleValue)))
182
+ && (panel.mapObject.zoomSettings.zoomFactor <= 1 || panel.mapObject.previousZoomFactor !==
183
+ panel.mapObject.zoomSettings.zoomFactor)) {
184
+ panel.mapObject.tileTranslatePoint.x = 0;
185
+ panel.mapObject.tileTranslatePoint.y = 0;
186
+ }
187
+ } else if (panel.mapObject.defaultState) {
188
+ panel.mapObject.previousZoomFactor = panel.mapObject.tileZoomLevel;
189
+ panel.mapObject.tileZoomLevel = zoomFactorValue;
190
+ panel.mapObject.tileTranslatePoint.x = 0;
191
+ panel.mapObject.tileTranslatePoint.y = 0;
192
+ }
193
+ if ( zoomFactorValue <= 1 && !isNullOrUndefined(panel.mapObject.height) && !panel.mapObject.zoomSettings.shouldZoomInitially
194
+ && (panel.mapObject.tileZoomLevel === panel.mapObject.tileZoomScale) && this.mapObject.initialCheck ) {
195
+ fixInitialScaleForTile(this.mapObject);
196
+ }
197
+ if (!isNullOrUndefined(panel.mapObject.centerLatOfGivenLocation) && !isNullOrUndefined(panel.mapObject.centerLongOfGivenLocation) &&
198
+ panel.mapObject.zoomNotApplied) {
199
+ centerTileMap.y = panel.mapObject.centerLatOfGivenLocation;
200
+ centerTileMap.x = panel.mapObject.centerLongOfGivenLocation;
201
+ panel.mapObject.tileZoomLevel = panel.mapObject.mapScaleValue = panel.mapObject.scaleOfGivenLocation;
202
+ }
203
+ panel.mapObject.tileTranslatePoint = panel.panTileMap(
204
+ panel.mapObject.availableSize.width, panel.mapObject.availableSize.height, centerTileMap
205
+ );
206
+ if (this.mapObject.zoomSettings.resetToInitial && this.mapObject.initialCheck && !isNullOrUndefined(panel.mapObject.height)
207
+ && this.mapObject.availableSize.height > 512) {
208
+ this.mapObject.applyZoomReset = true;
209
+ this.mapObject.initialZoomLevel = Math.floor(this.mapObject.availableSize.height / 512);
210
+ const padding : number = this.mapObject.layers[this.mapObject.baseLayerIndex].layerType !== 'GoogleStaticMap' ?
211
+ 20 : 0;
212
+ const totalSize : number = Math.pow(2, this.mapObject.initialZoomLevel) * 256;
213
+ this.mapObject.initialTileTranslate.x = (this.mapObject.availableSize.width / 2) - (totalSize / 2);
214
+ this.mapObject.initialTileTranslate.y = (this.mapObject.availableSize.height / 2) - (totalSize / 2) + padding;
215
+ }
216
+ panel.generateTiles(panel.mapObject.tileZoomLevel, panel.mapObject.tileTranslatePoint, null, bing);
217
+ if (!isNullOrUndefined(panel.mapObject.previousZoomFactor)
218
+ && panel.mapObject.previousZoomFactor !== panel.mapObject.zoomSettings.zoomFactor) {
219
+ panel.mapObject.previousZoomFactor = panel.mapObject.zoomSettings.zoomFactor;
220
+ }
221
+ if (panel.mapObject.navigationLineModule) {
222
+ panel.layerObject.appendChild(
223
+ panel.mapObject.navigationLineModule.renderNavigation(panel.currentLayer, panel.mapObject.tileZoomLevel, layerIndex)
224
+ );
225
+ }
226
+ if (panel.mapObject.markerModule) {
227
+ panel.mapObject.markerModule.markerRender(this.mapObject, panel.layerObject, layerIndex, panel.mapObject.tileZoomLevel, null);
228
+ }
229
+ panel.translateLayerElements(panel.layerObject, layerIndex);
230
+ panel.layerGroup.appendChild(panel.layerObject);
231
+ }
232
+
233
+
234
+ protected processLayers(layer: LayerSettings, layerIndex: number): void {
235
+ this.layerObject = (this.mapObject.renderer.createGroup({
236
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex
237
+ }));
238
+ if (!this.mapObject.enablePersistence) {
239
+ const itemName: string = this.mapObject.getModuleName() + this.mapObject.element.id;
240
+ if (navigator.userAgent.indexOf('Edge') === -1) {
241
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
242
+ let data: any;
243
+ try {
244
+ data = window.localStorage;
245
+ } catch (e) {
246
+ data = null;
247
+ }
248
+ if (!isNullOrUndefined(data) && window.localStorage.getItem(itemName)) {
249
+ window.localStorage.removeItem(itemName);
250
+ }
251
+ }
252
+ }
253
+ const eventArgs: ILayerRenderingEventArgs = {
254
+ cancel: false, name: layerRendering, index: layerIndex,
255
+ layer: layer, maps: this.mapObject, visible: layer.visible
256
+ };
257
+ this.mapObject.trigger('layerRendering', eventArgs, (observedArgs: ILayerRenderingEventArgs) => {
258
+ if (!eventArgs.cancel && eventArgs.visible) {
259
+ if (layer.layerType === 'OSM') {
260
+ layer.urlTemplate = 'https://a.tile.openstreetmap.org/level/tileX/tileY.png';
261
+ }
262
+ if (layer.layerType === 'Google') {
263
+ layer.urlTemplate = 'https://mt1.google.com/vt/lyrs=m@129&hl=en&x=tileX&y=tileY&z=level';
264
+ }
265
+ if (layer.layerType !== 'Geometry' || (isNullOrUndefined(layer.shapeData) && !isNullOrUndefined(layer.urlTemplate) && layer.urlTemplate !== '')) {
266
+ if (layer.layerType !== 'Bing' || this.bing) {
267
+ if (!isNullOrUndefined(layer.urlTemplate) && layer.urlTemplate.indexOf('quadkey') > -1) {
268
+ const bing: BingMap = new BingMap(this.mapObject);
269
+ this.bingMapCalculation(layer, layerIndex, this, bing);
270
+ } else {
271
+ this.renderTileLayer(this, layer, layerIndex);
272
+ }
273
+ } else if (layer.key && layer.key.length > 1) {
274
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
275
+ const proxy: LayerPanel = this;
276
+ const bing: BingMap = new BingMap(this.mapObject);
277
+ const bingType: string = layer.bingMapType === 'AerialWithLabel' ? 'AerialWithLabelsOnDemand' : layer.bingMapType;
278
+ const url: string = 'https://dev.virtualearth.net/REST/V1/Imagery/Metadata/' + bingType;
279
+ const ajax: Ajax = new Ajax({
280
+ url: url + '?output=json&include=ImageryProviders&urischeme=https&key=' + layer.key
281
+ });
282
+ ajax.onSuccess = (json: string) => {
283
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
284
+ const jsonObject: any = JSON.parse(json);
285
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
286
+ const resource: any = jsonObject['resourceSets'][0]['resources'][0];
287
+ const imageUrl: string = <string>resource['imageUrl'];
288
+ const subDomains: string[] = <string[]>resource['imageUrlSubdomains'];
289
+ const maxZoom: string = <string>resource['zoomMax'];
290
+ const markerGroupElement : HTMLElement = document.getElementById(proxy.mapObject.element.id + '_Markers_Group');
291
+ if (imageUrl !== null && imageUrl !== undefined && imageUrl !== bing.imageUrl) {
292
+ bing.imageUrl = imageUrl;
293
+ }
294
+ if (subDomains !== null && subDomains !== undefined && subDomains !== bing.subDomains) {
295
+ bing.subDomains = subDomains;
296
+ }
297
+ if (maxZoom !== null && maxZoom !== undefined && maxZoom !== bing.maxZoom) {
298
+ bing.maxZoom = maxZoom;
299
+ }
300
+ proxy.mapObject['bingMap'] = bing;
301
+ proxy.renderTileLayer(proxy, layer, layerIndex, bing);
302
+ this.mapObject.arrangeTemplate();
303
+ if (this.mapObject.zoomModule && (this.mapObject.previousScale !== this.mapObject.scale)) {
304
+ this.mapObject.zoomModule.applyTransform(this.mapObject, true);
305
+ }
306
+ };
307
+ ajax.send();
308
+ }
309
+ } else {
310
+ if (!isNullOrUndefined(layer.shapeData) && (!isNullOrUndefined(layer.shapeData['geometries']) ||
311
+ !isNullOrUndefined(layer.shapeData['features']))) {
312
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
313
+ const featureData: any[] = (!isNullOrUndefined(layer.shapeData['geometries']) &&
314
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
315
+ (<any[]>layer.shapeData['geometries']).length > 0 ? layer.shapeData['geometries'] :
316
+ layer.shapeData['features']);
317
+ layer.layerData = [];
318
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
319
+ const bbox: any = layer.shapeData['bbox'];
320
+ if (!isNullOrUndefined(bbox) && layer.isBaseLayer) {
321
+ this.mapObject.baseMapBounds = new GeoLocation(
322
+ { min: bbox[0][1], max: bbox[1][1] },
323
+ { min: bbox[0][0], max: bbox[1][0] }
324
+ );
325
+ } else if (isNullOrUndefined(this.mapObject.baseMapBounds) && !isCustomPath(featureData)) {
326
+ this.calculateRectBounds(featureData);
327
+ }
328
+ this.calculatePathCollection(layerIndex, featureData);
329
+ }
330
+ }
331
+ }
332
+ });
333
+ if (!this.mapObject.isTileMap) {
334
+ this.mapObject.svgObject.appendChild(this.layerGroup);
335
+ } else if (this.tileSvgObject) {
336
+ this.tileSvgObject.appendChild(this.layerGroup);
337
+ this.mapObject.baseMapBounds = null;
338
+ }
339
+ }
340
+
341
+ private bingMapCalculation(layer: LayerSettings, layerIndex: number, proxy: LayerPanel, bing: BingMap): void{
342
+ bing.imageUrl = layer.urlTemplate;
343
+ bing.subDomains = ['t0', 't1', 't2', 't3'];
344
+ bing.maxZoom = '21';
345
+ proxy.mapObject['bingMap'] = bing;
346
+ proxy.renderTileLayer(proxy, layer, layerIndex, bing);
347
+ this.mapObject.arrangeTemplate();
348
+ if (this.mapObject.zoomModule && (this.mapObject.previousScale !== this.mapObject.scale)) {
349
+ this.mapObject.zoomModule.applyTransform(this.mapObject, true);
350
+ }
351
+ }
352
+
353
+ private bubbleCalculation(bubbleSettings: BubbleSettingsModel, range: { min: number, max: number }): void {
354
+ if (bubbleSettings.dataSource != null && bubbleSettings != null) {
355
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
356
+ const bubbleDataSource: any[] = bubbleSettings.dataSource as any[];
357
+ for (let i: number = 0; i < bubbleDataSource.length; i++) {
358
+ const bubbledata: number = (!isNullOrUndefined(bubbleSettings.valuePath)) ? ((bubbleSettings.valuePath.indexOf('.') > -1) ?
359
+ Number(getValueFromObject(bubbleSettings.dataSource[i], bubbleSettings.valuePath)) :
360
+ parseFloat(bubbleSettings.dataSource[i][bubbleSettings.valuePath])) :
361
+ parseFloat(bubbleSettings.dataSource[i][bubbleSettings.valuePath]);
362
+ if (i !== 0) {
363
+ if (bubbledata > range.max) {
364
+ range.max = bubbledata;
365
+ } else if (bubbledata < range.min) {
366
+ range.min = bubbledata;
367
+ }
368
+ } else {
369
+ range.max = range.min = bubbledata;
370
+ }
371
+ }
372
+ }
373
+ }
374
+
375
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
376
+ public calculatePathCollection(layerIndex: number, renderData: any[]): void {
377
+ this.groupElements = [];
378
+ if ((!isCustomPath(renderData))) {
379
+ this.currentFactor = this.calculateFactor(this.currentLayer);
380
+ }
381
+ this.rectBounds = null;
382
+ const shapeSettings: ShapeSettings = <ShapeSettings>this.currentLayer.shapeSettings;
383
+ const bubbleSettings: BubbleSettings[] = <BubbleSettings[]>this.currentLayer.bubbleSettings;
384
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
385
+ Array.prototype.forEach.call(renderData, (geometryData: any, index: number) => {
386
+ if (!isNullOrUndefined(geometryData['geometry']) || !isNullOrUndefined(geometryData['coordinates'])) {
387
+ const type: string = !isNullOrUndefined(geometryData['geometry']) ? geometryData['geometry']['type'] : geometryData['type'];
388
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
389
+ const coords: any[] = !isNullOrUndefined(geometryData['geometry']) ? geometryData['geometry']['coordinates'] :
390
+ geometryData['coordinates'];
391
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
392
+ const data: any = geometryData['geometry'];
393
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
394
+ const properties: any = geometryData['properties'];
395
+ this.generatePoints(type, coords, data, properties);
396
+ }
397
+ });
398
+ this.currentLayer.rectBounds = this.rectBounds;
399
+ if (isNullOrUndefined(this.mapObject.baseMapRectBounds) && this.currentLayer.isBaseLayer) {
400
+ this.mapObject.baseMapRectBounds = this.rectBounds;
401
+ }
402
+ const colors: string[] = shapeSettings.palette.length > 1 ? shapeSettings.palette : getShapeColor(this.mapObject.theme);
403
+ const labelTemplateEle: HTMLElement = createElement('div', {
404
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_Label_Template_Group',
405
+ className: this.mapObject.element.id + '_template',
406
+ styles: 'pointer-events: none; overflow: hidden; position: absolute;' +
407
+ 'top:' + this.mapObject.mapAreaRect.y + 'px;' +
408
+ 'left:' + this.mapObject.mapAreaRect.x + 'px;' +
409
+ 'height:' + this.mapObject.mapAreaRect.height + 'px;' +
410
+ 'width:' + this.mapObject.mapAreaRect.width + 'px;'
411
+ });
412
+ if (this.currentLayer.layerData.length !== 0) {
413
+ for (let i: number = 0; i < this.currentLayer.layerData.length; i++) {
414
+ let k: number;
415
+ const borderValue: BorderModel = {
416
+ color: shapeSettings.border.color,
417
+ width: shapeSettings.border.width,
418
+ opacity: shapeSettings.border.opacity
419
+ };
420
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
421
+ const currentShapeData: any[] = <any[]>this.currentLayer.layerData[i];
422
+ let pathOptions: PathOption; let polyLineOptions: PolylineOption;
423
+ let circleOptions: CircleOption; let groupElement: Element; let drawObject: Element;
424
+ let path: string = ''; const points: string = '';
425
+ let fill: string = (shapeSettings.autofill) ? colors[i % colors.length] :
426
+ (shapeSettings.fill || this.mapObject.themeStyle.shapeFill);
427
+ if (shapeSettings.colorValuePath !== null && !isNullOrUndefined(currentShapeData['property'])) {
428
+ k = checkShapeDataFields(
429
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
430
+ <any[]>this.currentLayer.dataSource, currentShapeData['property'],
431
+ this.currentLayer.shapeDataPath, this.currentLayer.shapePropertyPath, this.currentLayer
432
+ );
433
+ if (k !== null && shapeSettings.colorMapping.length === 0) {
434
+ fill = ((this.currentLayer.shapeSettings.colorValuePath.indexOf('.') > -1) ?
435
+ (getValueFromObject(this.currentLayer.dataSource[k], shapeSettings.colorValuePath)) :
436
+ this.currentLayer.dataSource[k][shapeSettings.colorValuePath]);
437
+ } else if (currentShapeData['property'][shapeSettings.colorValuePath] &&
438
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
439
+ (<any[]>this.currentLayer.dataSource).length === 0 && shapeSettings.colorMapping.length === 0) {
440
+ fill = ((this.currentLayer.shapeSettings.colorValuePath.indexOf('.') > -1) ?
441
+ (getValueFromObject(currentShapeData['property'], shapeSettings.colorValuePath)) :
442
+ currentShapeData['property'][shapeSettings.colorValuePath]);
443
+ }
444
+ fill = !isNullOrUndefined(fill) ? fill : (shapeSettings.fill || this.mapObject.themeStyle.shapeFill);
445
+ }
446
+ const shapeID: string = this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_shapeIndex_' + i + '_dataIndex_' + k;
447
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
448
+ const getShapeColor: any = this.getShapeColorMapping(this.currentLayer, currentShapeData['property'], fill);
449
+ fill = Object.prototype.toString.call(getShapeColor) === '[object Object]' && !isNullOrUndefined(getShapeColor['fill'])
450
+ ? getShapeColor['fill'] : fill;
451
+ if (this.currentLayer.shapeSettings.borderColorValuePath || this.currentLayer.shapeSettings.borderWidthValuePath) {
452
+ const borderColorValue: string = this.currentLayer.shapeSettings.borderColorValuePath;
453
+ const borderWidthValue: string = this.currentLayer.shapeSettings.borderWidthValuePath;
454
+ k = checkShapeDataFields(
455
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
456
+ <any[]>this.currentLayer.dataSource, currentShapeData['property'],
457
+ this.currentLayer.shapeDataPath, this.currentLayer.shapePropertyPath, this.currentLayer
458
+ );
459
+ if (k !== null) {
460
+ if (this.currentLayer.dataSource[k][shapeSettings.borderColorValuePath]) {
461
+ borderValue.color = this.currentLayer.dataSource[k][shapeSettings.borderColorValuePath];
462
+ }
463
+ if (this.currentLayer.dataSource[k][shapeSettings.borderWidthValuePath]) {
464
+ borderValue.width = this.currentLayer.dataSource[k][shapeSettings.borderWidthValuePath];
465
+ }
466
+ }
467
+ }
468
+ const opacity: number = (Object.prototype.toString.call(getShapeColor) === '[object Object]'
469
+ && !isNullOrUndefined(getShapeColor['opacity'])) ? getShapeColor['opacity'] : shapeSettings.opacity;
470
+ const eventArgs: IShapeRenderingEventArgs = {
471
+ cancel: false, name: shapeRendering, index: i,
472
+ data: this.currentLayer.dataSource ? this.currentLayer.dataSource[k] : null,
473
+ maps: this.mapObject,
474
+ shape: shapeSettings, fill: fill,
475
+ border: { width: borderValue.width, color: borderValue.color, opacity: borderValue.opacity}
476
+ };
477
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
478
+ const shapeRenderingSuccess: any = (eventArgs: IShapeRenderingEventArgs) => {
479
+ let drawingType: string = !isNullOrUndefined(currentShapeData['_isMultiPolygon'])
480
+ ? 'MultiPolygon' : isNullOrUndefined(currentShapeData['type']) ? currentShapeData[0]['type'] : currentShapeData['type'];
481
+ drawingType = (drawingType === 'Polygon' || drawingType === 'MultiPolygon') ? 'Polygon' : drawingType;
482
+ if (!eventArgs.cancel) {
483
+ eventArgs.fill = eventArgs.fill === '#A6A6A6' ? eventArgs.shape.fill ||
484
+ this.mapObject.themeStyle.shapeFill : eventArgs.fill;
485
+ eventArgs.border.color = eventArgs.border.color === '#000000' ?
486
+ eventArgs.shape.border.color : eventArgs.border.color;
487
+ eventArgs.border.width = eventArgs.border.width === 0 ? eventArgs.shape.border.width : eventArgs.border.width;
488
+ if (isNullOrUndefined(shapeSettings.borderColorValuePath)) {
489
+ this.mapObject.layers[layerIndex].shapeSettings.border.color = eventArgs.border.color;
490
+ }
491
+ if (isNullOrUndefined(shapeSettings.borderWidthValuePath)) {
492
+ this.mapObject.layers[layerIndex].shapeSettings.border.width = eventArgs.border.width;
493
+ }
494
+ } else {
495
+ eventArgs.fill = fill;
496
+ eventArgs.border.color = shapeSettings.border.color;
497
+ eventArgs.border.width = shapeSettings.border.width;
498
+ this.mapObject.layers[layerIndex].shapeSettings.border = shapeSettings.border;
499
+ }
500
+ eventArgs.border.opacity = isNullOrUndefined(eventArgs.border.opacity) ? opacity : eventArgs.border.opacity;
501
+ if (this.groupElements.length < 1) {
502
+ groupElement = this.mapObject.renderer.createGroup({
503
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_' + drawingType + '_Group', transform: ''
504
+ });
505
+ this.groupElements.push(groupElement);
506
+ } else {
507
+ for (let i: number = 0; i < this.groupElements.length; i++) {
508
+ const ele: Element = this.groupElements[i];
509
+ if (ele.id.indexOf(drawingType) > -1) {
510
+ groupElement = ele;
511
+ break;
512
+ } else if (i >= this.groupElements.length - 1) {
513
+ groupElement = this.mapObject.renderer.createGroup({
514
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_' + drawingType + '_Group'
515
+ });
516
+ this.groupElements.push(groupElement);
517
+ break;
518
+ }
519
+ }
520
+ }
521
+ let pathEle: Element;
522
+ switch (drawingType) {
523
+ case 'Polygon':
524
+ if (!currentShapeData['_isMultiPolygon']) {
525
+ path += 'M' + (currentShapeData[0]['point']['x']) + ' ' + (currentShapeData[0]['point']['y']);
526
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
527
+ currentShapeData.map((shapeData: any) => {
528
+ path += ' L ' + (shapeData['point']['x']) + ' ' + (shapeData['point']['y']);
529
+ });
530
+ } else {
531
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
532
+ path = this.generateMultiPolygonPath(<any[]>currentShapeData);
533
+ }
534
+ path += ' z ';
535
+ if (path.length > 3) {
536
+ pathOptions = new PathOption(
537
+ shapeID, eventArgs.fill, eventArgs.border.width, eventArgs.border.color,
538
+ opacity, eventArgs.border.opacity, shapeSettings.dashArray, path);
539
+ pathEle = this.mapObject.renderer.drawPath(pathOptions) as SVGPathElement;
540
+ }
541
+ break;
542
+ case 'LineString':
543
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
544
+ currentShapeData.map((lineData: any, index: number) => {
545
+ if (index === 0) {
546
+ path += 'M ' + (lineData['point']['x']) + ' ' + (lineData['point']['y']);
547
+ } else {
548
+ path += 'L' + (lineData['point']['x']) + ' , ' + (lineData['point']['y']) + ' ';
549
+ }
550
+ });
551
+ if (path.length > 3) {
552
+ pathOptions = new PathOption(
553
+ shapeID, 'transparent', !isNullOrUndefined(eventArgs.border.width) ? eventArgs.border.width : 1, !isNullOrUndefined(eventArgs.fill) ? eventArgs.fill :
554
+ eventArgs.border.color,
555
+ opacity, eventArgs.border.opacity, shapeSettings.dashArray, path);
556
+ pathEle = this.mapObject.renderer.drawPath(pathOptions) as SVGPathElement;
557
+ }
558
+ break;
559
+ case 'MultiLineString':
560
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
561
+ currentShapeData.map((multilineData: any) => {
562
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
563
+ multilineData.map((lineData: any, index: number) => {
564
+ if (index === 0) {
565
+ path += 'M ' + (lineData['point']['x']) + ' ' + (lineData['point']['y']);
566
+ } else {
567
+ path += 'L' + (lineData['point']['x']) + ' , ' + (lineData['point']['y']) + ' ';
568
+ }
569
+ });
570
+ });
571
+ if (path.length > 3) {
572
+ pathOptions = new PathOption(
573
+ shapeID, 'transparent', !isNullOrUndefined(eventArgs.border.width) ? eventArgs.border.width : 1, !isNullOrUndefined(eventArgs.fill) ? eventArgs.fill :
574
+ eventArgs.border.color,
575
+ opacity, eventArgs.border.opacity, shapeSettings.dashArray, path);
576
+ pathEle = this.mapObject.renderer.drawPath(pathOptions) as SVGPathElement;
577
+ }
578
+ break;
579
+ case 'Point':
580
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
581
+ const pointData: any = <any>currentShapeData['point'];
582
+ const circleRadius: number = (this.mapObject.layers[layerIndex].type !== 'SubLayer') ? shapeSettings.circleRadius : shapeSettings.circleRadius / (this.mapObject.isTileMap ? this.mapObject.scale : this.currentFactor);
583
+ circleOptions = new CircleOption(
584
+ shapeID, eventArgs.fill, eventArgs.border, opacity,
585
+ pointData['x'], pointData['y'], circleRadius, shapeSettings.dashArray);
586
+ pathEle = this.mapObject.renderer.drawCircle(circleOptions) as SVGCircleElement;
587
+ break;
588
+ case 'MultiPoint':
589
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
590
+ currentShapeData.map((multiPointData: any, index: number) => {
591
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
592
+ const pointData: any = multiPointData['point'];
593
+ const circleRadius: number = (this.mapObject.layers[layerIndex].type !== 'SubLayer') ? shapeSettings.circleRadius : shapeSettings.circleRadius / (this.mapObject.isTileMap ? this.mapObject.scale : this.currentFactor);
594
+ circleOptions = new CircleOption(
595
+ (shapeID + "_multiLine_" + index), eventArgs.fill, eventArgs.border, opacity,
596
+ pointData['x'], pointData['y'], circleRadius, shapeSettings.dashArray);
597
+ pathEle = this.mapObject.renderer.drawCircle(circleOptions) as SVGCircleElement;
598
+ this.pathAttributeCalculate(groupElement, pathEle, drawingType, currentShapeData, i);
599
+ });
600
+ break;
601
+ case 'Path':
602
+ path = <string>currentShapeData['point'];
603
+ pathOptions = new PathOption(
604
+ shapeID, eventArgs.fill, eventArgs.border.width, eventArgs.border.color,
605
+ opacity, eventArgs.border.opacity, shapeSettings.dashArray, path);
606
+ pathEle = this.mapObject.renderer.drawPath(pathOptions) as SVGPathElement;
607
+ break;
608
+ }
609
+ if (!isNullOrUndefined(pathEle) && drawingType !== 'MultiPoint') {
610
+ this.pathAttributeCalculate(groupElement, pathEle, drawingType, currentShapeData, i);
611
+ }
612
+ if (i === this.currentLayer.layerData.length - 1) {
613
+ this.layerFeatures(layerIndex, colors, renderData, labelTemplateEle);
614
+ }
615
+ };
616
+ shapeRenderingSuccess.bind(this);
617
+ this.mapObject.trigger('shapeRendering', eventArgs, shapeRenderingSuccess);
618
+ }
619
+ } else {
620
+ this.layerFeatures(layerIndex, colors, renderData, labelTemplateEle);
621
+ }
622
+ }
623
+ /**
624
+ * layer features as bubble, marker, datalabel, navigation line.
625
+ *
626
+ * @param {groupElement} Element - Specifies the element to append the group
627
+ * @param {pathEle} Element - Specifies the svg element
628
+ * @param {drawingType} string - Specifies the data type
629
+ * @param {currentShapeData} any - Specifies the layer of shapedata.
630
+ * @param {index} number - Specifies the tab index.
631
+ * @returns {void}
632
+ */
633
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
634
+ private pathAttributeCalculate(groupElement: Element, pathEle: Element, drawingType: string,
635
+ currentShapeData: any, index: number): void {
636
+ const property: string[] = (Object.prototype.toString.call(this.currentLayer.shapePropertyPath) === '[object Array]' ?
637
+ this.currentLayer.shapePropertyPath : [this.currentLayer.shapePropertyPath]) as string[];
638
+ let properties: string;
639
+ for (let j: number = 0; j < property.length; j++) {
640
+ if (!isNullOrUndefined(currentShapeData['property'])) {
641
+ properties = property[j];
642
+ break;
643
+ }
644
+ }
645
+ pathEle.setAttribute('aria-label', ((!isNullOrUndefined(currentShapeData['property'])) ?
646
+ (currentShapeData['property'][properties]) : ''));
647
+ pathEle.setAttribute('tabindex', (this.mapObject.tabIndex + index + 3).toString());
648
+ pathEle.setAttribute('role', '');
649
+ if (drawingType === 'LineString' || drawingType === 'MultiLineString') {
650
+ pathEle.setAttribute('style', 'outline:none');
651
+ }
652
+ maintainSelection(this.mapObject.selectedElementId, this.mapObject.shapeSelectionClass, pathEle,
653
+ 'ShapeselectionMapStyle');
654
+ if (this.mapObject.toggledShapeElementId) {
655
+ for (let j: number = 0; j < this.mapObject.toggledShapeElementId.length; j++) {
656
+ const styleProperty: ShapeSettingsModel | ToggleLegendSettingsModel =
657
+ this.mapObject.legendSettings.toggleLegendSettings.applyShapeSettings ?
658
+ this.currentLayer.shapeSettings : this.mapObject.legendSettings.toggleLegendSettings;
659
+ if (this.mapObject.toggledShapeElementId[j] === pathEle.id) {
660
+ pathEle.setAttribute('fill', styleProperty.fill);
661
+ pathEle.setAttribute('stroke', styleProperty.border.color);
662
+ pathEle.setAttribute('fill-opacity', (styleProperty.opacity).toString());
663
+ pathEle.setAttribute('stroke-opacity', (isNullOrUndefined(styleProperty.border.opacity) ? styleProperty.opacity : styleProperty.border.opacity).toString());
664
+ pathEle.setAttribute('stroke-width', (styleProperty.border.width).toString());
665
+ }
666
+ }
667
+ }
668
+ groupElement.appendChild(pathEle);
669
+ }
670
+ /**
671
+ * layer features as bubble, marker, datalabel, navigation line.
672
+ *
673
+ * @param {number} layerIndex - Specifies the layer index
674
+ * @param {string[]} colors - Specifies the colors
675
+ * @param {Object[]} renderData - Specifies the render data
676
+ * @param {HTMLElement} labelTemplateEle - Specifies the label template element
677
+ * @returns {void}
678
+ */
679
+ private layerFeatures(
680
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
681
+ layerIndex: number, colors: string[], renderData: any[],
682
+ labelTemplateEle: HTMLElement
683
+ ): void {
684
+ let bubbleG: Element;
685
+ if (this.currentLayer.bubbleSettings.length && this.mapObject.bubbleModule) {
686
+ const length: number = this.currentLayer.bubbleSettings.length;
687
+ let bubble: BubbleSettingsModel;
688
+ for (let j: number = 0; j < length; j++) {
689
+ bubble = this.currentLayer.bubbleSettings[j];
690
+ bubbleG = this.mapObject.renderer.createGroup({
691
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_bubble_Group_' + j
692
+ });
693
+ const range: {
694
+ min: number;
695
+ max: number;
696
+ } = { min: 0, max: 0 };
697
+ this.bubbleCalculation(bubble, range);
698
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
699
+ const bubbleDataSource: any[] = bubble.dataSource as any[];
700
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
701
+ bubbleDataSource.map((bubbleData: any, i: number) => {
702
+ this.renderBubble(
703
+ this.currentLayer, bubbleData, colors[i % colors.length], range, j, i, bubbleG, layerIndex, bubble);
704
+ });
705
+ this.groupElements.push(bubbleG);
706
+ }
707
+ }
708
+ if ((this.mapObject.markerModule && !this.mapObject.isTileMap) && this.mapObject.zoomSettings.enable) {
709
+ this.mapObject.markerModule.calculateZoomCenterPositionAndFactor(this.mapObject.layersCollection);
710
+ }
711
+ const group: Element = (this.mapObject.renderer.createGroup({
712
+ id: this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_dataLableIndex_Group',
713
+ style: 'pointer-events: none;'
714
+ }));
715
+ if (this.mapObject.dataLabelModule && this.currentLayer.dataLabelSettings.visible) {
716
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
717
+ const intersect: any[] = [];
718
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
719
+ renderData.map((currentShapeData: any[], i: number) => {
720
+ this.renderLabel(this.currentLayer, layerIndex, currentShapeData, group, i, labelTemplateEle, intersect);
721
+ });
722
+ this.groupElements.push(group);
723
+ }
724
+ if (this.mapObject.navigationLineModule) {
725
+ this.groupElements.push(
726
+ this.mapObject.navigationLineModule.renderNavigation(this.currentLayer, this.currentFactor, layerIndex)
727
+ );
728
+ }
729
+ this.groupElements.map((element: Element) => {
730
+ this.layerObject.appendChild(element);
731
+ });
732
+ if (this.mapObject.markerModule) {
733
+ this.mapObject.markerModule.markerRender(this.mapObject,
734
+ this.layerObject, layerIndex, (this.mapObject.isTileMap ? Math.floor(this.currentFactor)
735
+ : this.currentFactor),
736
+ null
737
+ );
738
+ }
739
+ this.translateLayerElements(this.layerObject, layerIndex);
740
+ this.layerGroup.appendChild(this.layerObject);
741
+ }
742
+
743
+ /**
744
+ * render datalabel
745
+ *
746
+ * @param {LayerSettings} layer - Specifies the layer
747
+ * @param {number} layerIndex - Specifies the layer index
748
+ * @param {object[]} shape - Specifies the shape
749
+ * @param {Element} group - Specifies the group
750
+ * @param {number} shapeIndex - Specifies the shape index
751
+ * @param {HTMLElement} labelTemplateEle - Specifies the label template element
752
+ * @param {object[]} intersect - Specifies the intersect
753
+ * @returns {void}
754
+ */
755
+ private renderLabel(
756
+ layer: LayerSettings, layerIndex: number,
757
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
758
+ shape: any[], group: Element, shapeIndex: number, labelTemplateEle: HTMLElement, intersect: any[]
759
+ ): void {
760
+ this.mapObject.dataLabelModule.renderLabel(
761
+ layer, layerIndex, shape, layer.layerData, group, labelTemplateEle, shapeIndex, intersect
762
+ );
763
+ }
764
+ /**
765
+ * To render path for multipolygon
766
+ *
767
+ * @param {any[]} currentShapeData Specifies the current shape data
768
+ * @returns {string} Returns the path
769
+ */
770
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
771
+ private generateMultiPolygonPath(currentShapeData: any[]): string {
772
+ let path: string = '';
773
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
774
+ let shape: any[];
775
+ for (let j: number = 0; j < currentShapeData.length; j++) {
776
+ path += 'M' + (currentShapeData[j][0]['point']['x']) + ' ' + (currentShapeData[j][0]['point']['y']);
777
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
778
+ shape = <any[]>currentShapeData[j];
779
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
780
+ shape.map((shapeData: any) => {
781
+ path += ' L ' + (shapeData['point']['x']) + ' ' + (shapeData['point']['y']);
782
+ });
783
+ }
784
+ return path;
785
+ }
786
+ /**
787
+ * To render bubble
788
+ *
789
+ * @param {LayerSettings} layer - Specifies the layer
790
+ * @param {object} bubbleData - Specifies the bubble data
791
+ * @param {string} color - Specifies the color
792
+ * @param {number} range - Specifies the range
793
+ * @param {number} bubbleIndex - Specifies the bubble index
794
+ * @param {number} dataIndex - Specifies the data index
795
+ * @param {number} group - Specifies the group
796
+ * @param {number} layerIndex - Specifies the layer index
797
+ * @param {BubbleSettingsModel} bubbleSettings - Specifies the bubble settings
798
+ * @returns {void}
799
+ */
800
+ private renderBubble(
801
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
802
+ layer: LayerSettings, bubbleData: any, color: string, range: { min: number, max: number },
803
+ bubbleIndex: number, dataIndex: number, group: Element, layerIndex: number, bubbleSettings: BubbleSettingsModel
804
+ ): void {
805
+ if (isNullOrUndefined(this.mapObject.bubbleModule) || !bubbleSettings.visible) {
806
+ return null;
807
+ }
808
+ color = bubbleSettings.fill ? bubbleSettings.fill : color;
809
+ this.mapObject.bubbleModule.id = this.mapObject.element.id + '_LayerIndex_' + layerIndex + '_BubbleIndex_' +
810
+ bubbleIndex + '_dataIndex_' + dataIndex;
811
+ this.mapObject.bubbleModule.renderBubble(
812
+ bubbleSettings, bubbleData, color, range, bubbleIndex, dataIndex, layerIndex, layer, group, this.mapObject.bubbleModule.id);
813
+ }
814
+ /**
815
+ * To get the shape color from color mapping module
816
+ *
817
+ * @param {LayerSettingsModel} layer - Specifies the layer
818
+ * @param {object} shape - Specifies the shape
819
+ * @param {string} color - Specifies the color
820
+ * @returns {Object} - Returns the object
821
+ */
822
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
823
+ private getShapeColorMapping(layer: LayerSettingsModel, shape: any, color: string): any {
824
+ color = color ? color : layer.shapeSettings.fill;
825
+ if (layer.shapeSettings.colorMapping.length === 0 && isNullOrUndefined(layer.dataSource)) {
826
+ return color;
827
+ }
828
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
829
+ const index: number = checkShapeDataFields(<any[]>layer.dataSource, shape, layer.shapeDataPath, layer.shapePropertyPath, layer);
830
+ const colorMapping: ColorMapping = new ColorMapping(this.mapObject);
831
+ if (isNullOrUndefined(layer.dataSource[index])) {
832
+ return color;
833
+ }
834
+ return colorMapping.getShapeColorMapping(layer.shapeSettings, layer.dataSource[index], color);
835
+ }
836
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
837
+ public generatePoints(type: string, coordinates: any[], data: any, properties: any): void {
838
+ let latitude: number; let longitude: number;
839
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
840
+ let newData: any[] = [];
841
+ switch (type.toLowerCase()) {
842
+ case 'polygon':
843
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
844
+ newData = <any[]>this.calculatePolygonBox(<any[]>coordinates[0], data, properties);
845
+ if (newData.length > 0) {
846
+ newData['property'] = properties;
847
+ newData['type'] = type;
848
+ newData['_isMultiPolygon'] = false;
849
+ this.currentLayer.layerData.push(newData);
850
+ }
851
+ break;
852
+ case 'multipolygon':
853
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
854
+ const multiPolygonDatas: any[] = [];
855
+ for (let i: number = 0; i < coordinates.length; i++) {
856
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
857
+ newData = <any[]>this.calculatePolygonBox(<any[]>coordinates[i][0], data, properties);
858
+ if (newData.length > 0) {
859
+ multiPolygonDatas.push(newData);
860
+ }
861
+ }
862
+ multiPolygonDatas['property'] = properties;
863
+ multiPolygonDatas['type'] = type;
864
+ multiPolygonDatas['_isMultiPolygon'] = true;
865
+ this.currentLayer.layerData.push(multiPolygonDatas);
866
+ break;
867
+ case 'linestring':
868
+ const extraSpace: number = !isNullOrUndefined(this.currentLayer.shapeSettings.border.width) ?
869
+ (typeof(this.currentLayer.shapeSettings.border.width) === 'string' ?
870
+ parseInt(this.currentLayer.shapeSettings.border.width, 10) : this.currentLayer.shapeSettings.border.width) : 1;
871
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
872
+ coordinates.map((points: any, index: number) => {
873
+ latitude = <number>points[1];
874
+ longitude = <number>points[0];
875
+ const point: Point = convertGeoToPoint(
876
+ latitude, longitude, this.currentFactor, this.currentLayer, this.mapObject);
877
+ this.calculateBox(point, extraSpace);
878
+ newData.push({
879
+ point: point, lat: latitude, lng: longitude
880
+ });
881
+ });
882
+ newData['property'] = properties;
883
+ newData['type'] = type;
884
+ this.currentLayer.layerData.push(newData);
885
+ break;
886
+ case 'multilinestring':
887
+ const extraSpaces: number = !isNullOrUndefined(this.currentLayer.shapeSettings.border.width) ?
888
+ (typeof(this.currentLayer.shapeSettings.border.width) === 'string' ?
889
+ parseInt(this.currentLayer.shapeSettings.border.width, 10) : this.currentLayer.shapeSettings.border.width) : 1;
890
+ const multiLineData: any[] = [];
891
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
892
+ coordinates.map((multiPoints: any) => {
893
+ newData = [];
894
+ multiPoints.map((points: any) => {
895
+ latitude = <number>points[1];
896
+ longitude = <number>points[0];
897
+ const point: Point = convertGeoToPoint(
898
+ latitude, longitude, this.currentFactor, this.currentLayer, this.mapObject);
899
+ this.calculateBox(point, extraSpaces);
900
+ newData.push({
901
+ point: point, lat: latitude, lng: longitude
902
+ });
903
+ });
904
+ multiLineData.push(newData);
905
+ });
906
+ multiLineData['property'] = properties;
907
+ multiLineData['type'] = type;
908
+ this.currentLayer.layerData.push(multiLineData);
909
+ break;
910
+ case 'point':
911
+ const pointExtraSpace: number = (!isNullOrUndefined(this.currentLayer.shapeSettings.border.width) ?
912
+ (typeof(this.currentLayer.shapeSettings.border.width) === 'string' ?
913
+ parseInt(this.currentLayer.shapeSettings.border.width, 10) : this.currentLayer.shapeSettings.border.width) : 1) +
914
+ (this.currentLayer.shapeSettings.circleRadius * 2);
915
+ latitude = <number>coordinates[1];
916
+ longitude = <number>coordinates[0];
917
+ const point: Point = convertGeoToPoint(latitude, longitude, this.currentFactor, this.currentLayer, this.mapObject);
918
+ this.calculateBox(point, pointExtraSpace);
919
+ this.currentLayer.layerData.push({
920
+ point: point, type: type, lat: latitude, lng: longitude, property: properties
921
+ });
922
+ break;
923
+ case 'multipoint': {
924
+ const extraSpace: number = (!isNullOrUndefined(this.currentLayer.shapeSettings.border.width) ?
925
+ (typeof(this.currentLayer.shapeSettings.border.width) === 'string' ?
926
+ parseInt(this.currentLayer.shapeSettings.border.width, 10) : this.currentLayer.shapeSettings.border.width) : 1) +
927
+ (this.currentLayer.shapeSettings.circleRadius * 2);
928
+ newData = [];
929
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
930
+ coordinates.map((points: any) => {
931
+ latitude = points[1];
932
+ longitude = points[0];
933
+ const point: Point = convertGeoToPoint(latitude, longitude, this.currentFactor, this.currentLayer, this.mapObject);
934
+ this.calculateBox(point, extraSpace);
935
+ newData.push({
936
+ point: point, lat: latitude, lng: longitude
937
+ });
938
+ });
939
+ newData['property'] = properties;
940
+ newData['type'] = type;
941
+ this.currentLayer.layerData.push(newData);
942
+ break;
943
+ }
944
+ case 'path':
945
+ this.currentLayer.layerData.push({
946
+ point: data['d'], type: type, property: properties
947
+ });
948
+ break;
949
+ }
950
+ }
951
+
952
+ public calculateBox(point: Point, extraSpace: number): void {
953
+ if (isNullOrUndefined(this.rectBounds)) {
954
+ this.rectBounds = { min: { x: point.x - extraSpace, y: point.y - extraSpace }, max: { x: point.x + extraSpace, y: point.y + extraSpace } };
955
+ } else {
956
+ this.rectBounds['min']['x'] = Math.min(this.rectBounds['min']['x'], point.x - extraSpace);
957
+ this.rectBounds['min']['y'] = Math.min(this.rectBounds['min']['y'], point.y - extraSpace);
958
+ this.rectBounds['max']['x'] = Math.max(this.rectBounds['max']['x'], point.x + extraSpace);
959
+ this.rectBounds['max']['y'] = Math.max(this.rectBounds['max']['y'], point.y + extraSpace);
960
+ }
961
+ }
962
+
963
+ public calculateFactor(layer: LayerSettings): number {
964
+ let horFactor: number; let verFactor: number = 1;
965
+ const divide: number = 10;
966
+ const exp: string = 'e+1';
967
+ const bounds: GeoLocation = this.mapObject.baseMapBounds;
968
+ const mapSize: Size = new Size(this.mapObject.mapAreaRect.width, this.mapObject.mapAreaRect.height - 5);
969
+ let mapHeight: number; let mapWidth: number;
970
+ if (bounds) {
971
+ const start: Point = convertGeoToPoint(
972
+ bounds.latitude.min, bounds.longitude.min, null, layer, this.mapObject);
973
+ const end: Point = convertGeoToPoint(
974
+ bounds.latitude.max, bounds.longitude.max, null, layer, this.mapObject);
975
+ mapHeight = end.y - start.y;
976
+ mapWidth = end.x - start.x;
977
+ if (mapHeight === 0 || mapWidth === 0) {
978
+ mapWidth = mapSize.width / 2;
979
+ mapHeight = mapSize.height;
980
+ }
981
+ } else {
982
+ mapHeight = mapWidth = 500;
983
+ }
984
+ if (mapHeight < mapSize.height) {
985
+ horFactor = parseFloat(Math.abs(Number(mapSize.height / Number(mapHeight.toString() + exp)) * 100).toString().split('.')[0])
986
+ / divide;
987
+ } else {
988
+ horFactor = mapSize.height / mapHeight;
989
+ }
990
+ if (mapWidth < mapSize.width) {
991
+ verFactor = parseFloat(Math.abs(Number(mapSize.width / Number(mapWidth.toString() + exp)) * 100).toString().split('.')[0])
992
+ / divide;
993
+ } else {
994
+ verFactor = mapSize.width / mapWidth;
995
+ }
996
+ return (Math.min(verFactor, horFactor));
997
+ }
998
+
999
+ public translateLayerElements(layerElement: Element, index: number): void {
1000
+ let childNode: HTMLElement;
1001
+ this.mapObject.translateType = 'layer';
1002
+ if (!isNullOrUndefined(this.mapObject.baseMapRectBounds)) {
1003
+ const duration: number = this.currentLayer.animationDuration;
1004
+ const animate: boolean = duration !== 0 || isNullOrUndefined(this.mapObject.zoomModule);
1005
+ this.mapObject.baseTranslatePoint = this.mapObject.zoomTranslatePoint;
1006
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1007
+ let translate: any;
1008
+ if (this.mapObject.zoomSettings.zoomFactor > 1 && !isNullOrUndefined(this.mapObject.zoomModule)) {
1009
+ translate = getZoomTranslate(this.mapObject, this.currentLayer, animate);
1010
+ } else {
1011
+ translate = getTranslate(this.mapObject, this.currentLayer, animate);
1012
+ }
1013
+ const scale: number = this.mapObject.previousScale = translate['scale'];
1014
+ const location: Point = this.mapObject.previousPoint = translate['location'] as Point;
1015
+ this.mapObject.baseTranslatePoint = this.mapObject.translatePoint = location;
1016
+ this.mapObject.baseScale = this.mapObject.scale = scale;
1017
+ for (let i: number = 0; i < layerElement.childElementCount; i++) {
1018
+ childNode = layerElement.childNodes[i] as HTMLElement;
1019
+ if (!(childNode.id.indexOf('_Markers_Group') > -1) &&
1020
+ (!(childNode.id.indexOf('_bubble_Group') > -1)) &&
1021
+ (!(childNode.id.indexOf('_dataLableIndex_Group') > -1))
1022
+ ) {
1023
+ const transform: string = 'scale( ' + scale + ' ) '
1024
+ + 'translate( ' + location.x + ' ' + location.y + ' ) ';
1025
+ childNode.setAttribute('transform', transform);
1026
+ if (duration > 0 && !isNullOrUndefined(this.mapObject.zoomModule)) {
1027
+ if (this.mapObject.zoomSettings.zoomFactor > 1) {
1028
+ translate = getZoomTranslate(this.mapObject, this.currentLayer);
1029
+ } else {
1030
+ translate = getTranslate(this.mapObject, this.currentLayer);
1031
+ }
1032
+ this.mapObject.scale = translate['scale'];
1033
+ this.mapObject.zoomTranslatePoint = this.mapObject.translatePoint = translate['location'] as Point;
1034
+ }
1035
+ }
1036
+ }
1037
+ } else if (this.mapObject.isTileMap && !isNullOrUndefined(this.mapObject.scale)) {
1038
+ for (let j: number = 0; j < layerElement.childElementCount; j++) {
1039
+ childNode = layerElement.childNodes[j] as HTMLElement;
1040
+ if (!(childNode.id.indexOf('_Markers_Group') > -1) &&
1041
+ (!(childNode.id.indexOf('_bubble_Group') > -1)) &&
1042
+ (!(childNode.id.indexOf('_dataLableIndex_Group') > -1)) &&
1043
+ (!(childNode.id.indexOf('_line_Group') > -1))) {
1044
+ const transform: string = 'scale( ' + this.mapObject.scale + ' ) ' + 'translate( ' + this.mapObject.translatePoint.x
1045
+ + ' ' + this.mapObject.translatePoint.y + ' ) ';
1046
+ childNode.setAttribute('transform', transform);
1047
+ }
1048
+ }
1049
+ }
1050
+ }
1051
+
1052
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1053
+ public calculateRectBounds(layerData: any[]): void {
1054
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1055
+ Array.prototype.forEach.call(layerData, (obj: any, index: number) => {
1056
+ if (!isNullOrUndefined(obj['geometry']) || !isNullOrUndefined(obj['coordinates'])) {
1057
+ const type: string = !isNullOrUndefined(obj['geometry']) ? obj['geometry']['type'] : obj['type'];
1058
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1059
+ const coordinates: any[] = !isNullOrUndefined(obj['geometry']) ? obj['geometry']['coordinates'] : obj['coordinates'];
1060
+ switch (type.toLowerCase()) {
1061
+ case 'polygon':
1062
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1063
+ this.calculateRectBox(<any[]>coordinates[0]);
1064
+ break;
1065
+ case 'multipolygon':
1066
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1067
+ coordinates.map((point: any, index: number) => {
1068
+ this.calculateRectBox(point[0]);
1069
+ });
1070
+ break;
1071
+ case 'multilinestring':
1072
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1073
+ coordinates.map((multiPoint: any, index: number) => {
1074
+ multiPoint.map((point: any, index: number) => {
1075
+ this.calculateRectBox(point, 'multilinestring', index === 0 ? true : false);
1076
+ });
1077
+ });
1078
+ break;
1079
+ case 'linestring':
1080
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1081
+ coordinates.map((point: any, index: number) => {
1082
+ this.calculateRectBox(point, 'linestring', index === 0 ? true : false);
1083
+ });
1084
+ break;
1085
+ case 'point':
1086
+ this.calculateRectBox(coordinates, 'point');
1087
+ break;
1088
+ case 'multipoint':
1089
+ coordinates.map((point: any, index: number) => {
1090
+ this.calculateRectBox(point, 'multipoint', index === 0 ? true : false);
1091
+ });
1092
+ break;
1093
+ }
1094
+ }
1095
+ });
1096
+ }
1097
+
1098
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1099
+ public calculatePolygonBox(coordinates: any[], data: any, properties: any): any {
1100
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1101
+ const newData: any[] = [];
1102
+ const bounds: GeoLocation = this.mapObject.baseMapBounds;
1103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1104
+ coordinates.map((currentPoint: any, index: number) => {
1105
+ const latitude: number = currentPoint[1];
1106
+ const longitude: number = currentPoint[0];
1107
+ if ((longitude >= bounds.longitude.min && longitude <= bounds.longitude.max)
1108
+ && (latitude >= bounds.latitude.min && latitude <= bounds.latitude.max)) {
1109
+ const point: Point = convertGeoToPoint(
1110
+ latitude, longitude, this.currentFactor, this.currentLayer, this.mapObject
1111
+ );
1112
+ if (isNullOrUndefined(this.rectBounds)) {
1113
+ this.rectBounds = { min: { x: point.x, y: point.y }, max: { x: point.x, y: point.y } };
1114
+ } else {
1115
+ this.rectBounds['min']['x'] = Math.min(this.rectBounds['min']['x'], point.x);
1116
+ this.rectBounds['min']['y'] = Math.min(this.rectBounds['min']['y'], point.y);
1117
+ this.rectBounds['max']['x'] = Math.max(this.rectBounds['max']['x'], point.x);
1118
+ this.rectBounds['max']['y'] = Math.max(this.rectBounds['max']['y'], point.y);
1119
+ }
1120
+ newData.push({
1121
+ point: point,
1122
+ lat: latitude,
1123
+ lng: longitude
1124
+ });
1125
+ }
1126
+ });
1127
+ return newData;
1128
+ }
1129
+
1130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1131
+ public calculateRectBox(coordinates: any[], type?: string, isFirstItem?: boolean): void {
1132
+ if ((type !== 'linestring' && type !== 'multilinestring') && (type !== 'point' && type !== 'multipoint')) {
1133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1134
+ Array.prototype.forEach.call(coordinates, (currentCoords: any) => {
1135
+ if (isNullOrUndefined(this.mapObject.baseMapBounds)) {
1136
+ this.mapObject.baseMapBounds = new GeoLocation(
1137
+ { min: currentCoords[1], max: currentCoords[1] },
1138
+ { min: currentCoords[0], max: currentCoords[0] });
1139
+ } else {
1140
+ this.mapObject.baseMapBounds.latitude.min = Math.min(this.mapObject.baseMapBounds.latitude.min, currentCoords[1]);
1141
+ this.mapObject.baseMapBounds.latitude.max = Math.max(this.mapObject.baseMapBounds.latitude.max, currentCoords[1]);
1142
+ this.mapObject.baseMapBounds.longitude.min = Math.min(this.mapObject.baseMapBounds.longitude.min, currentCoords[0]);
1143
+ this.mapObject.baseMapBounds.longitude.max = Math.max(this.mapObject.baseMapBounds.longitude.max, currentCoords[0]);
1144
+ }
1145
+ });
1146
+ } else {
1147
+ if ((isFirstItem || type === 'point') && isNullOrUndefined(this.mapObject.baseMapBounds)) {
1148
+ this.mapObject.baseMapBounds = new GeoLocation(
1149
+ { min: coordinates[1], max: coordinates[1] },
1150
+ { min: coordinates[0], max: coordinates[0] });
1151
+ } else {
1152
+ this.mapObject.baseMapBounds.latitude.min = Math.min(this.mapObject.baseMapBounds.latitude.min, coordinates[1]);
1153
+ this.mapObject.baseMapBounds.latitude.max = Math.max(this.mapObject.baseMapBounds.latitude.max, coordinates[1]);
1154
+ this.mapObject.baseMapBounds.longitude.min = Math.min(this.mapObject.baseMapBounds.longitude.min, coordinates[0]);
1155
+ this.mapObject.baseMapBounds.longitude.max = Math.max(this.mapObject.baseMapBounds.longitude.max, coordinates[0]);
1156
+ }
1157
+ }
1158
+ }
1159
+ public generateTiles(zoomLevel: number, tileTranslatePoint: Point, zoomType?: string, bing?: BingMap, position?: Point): void {
1160
+ const userLang: string = this.mapObject.locale;
1161
+ const size: Size = this.mapObject.availableSize;
1162
+ this.tiles = [];
1163
+ let xcount: number;
1164
+ let ycount: number;
1165
+ xcount = ycount = Math.pow(2, zoomLevel);
1166
+ let xLeft: number = 0; let xRight: number = 0;
1167
+ if ((tileTranslatePoint.x + (xcount * 256)) < size.width) {
1168
+ xLeft = tileTranslatePoint.x > 0 ? Math.ceil(tileTranslatePoint.x / 256) : 0;
1169
+ xRight = ((tileTranslatePoint.x + xcount * 256) < size.width) ?
1170
+ Math.ceil((size.width - (tileTranslatePoint.x + xcount * 256)) / 256) : 0;
1171
+ }
1172
+ xcount += xLeft + xRight;
1173
+ if (zoomType === 'Pan') {
1174
+ xcount = (this.horizontalPanXCount >= xcount) ? this.horizontalPanXCount : xcount;
1175
+ this.horizontalPan = false;
1176
+ } else {
1177
+ this.horizontalPanXCount = xcount;
1178
+ this.horizontalPan = true;
1179
+ }
1180
+ const baseLayer: LayerSettingsModel = this.mapObject.layers[this.mapObject.baseLayerIndex];
1181
+ this.urlTemplate = baseLayer.urlTemplate;
1182
+ const endY: number = Math.min(ycount, ((-tileTranslatePoint.y + size.height) / 256) + 1);
1183
+ const endX: number = Math.min(xcount, ((-tileTranslatePoint.x + size.width + (xRight * 256)) / 256) + 1);
1184
+ const startX: number = (-((tileTranslatePoint.x + (xLeft * 256)) + 256) / 256);
1185
+ const startY: number = (-(tileTranslatePoint.y + 256) / 256);
1186
+ bing = bing || this.bing || this.mapObject['bingMap'];
1187
+ for (let i: number = Math.round(startX); i < Math.round(endX); i++) {
1188
+ for (let j: number = Math.round(startY); j < Math.round(endY); j++) {
1189
+ const x: number = 256 * i + tileTranslatePoint.x;
1190
+ const y: number = 256 * j + tileTranslatePoint.y;
1191
+ if (x > -256 && x <= size.width && y > -256 && y < size.height) {
1192
+ if (j >= 0) {
1193
+ let tileI: number = i;
1194
+ if (i < 0) {
1195
+ tileI = (tileI % ycount) + ycount;
1196
+ }
1197
+ const tile: Tile = new Tile(tileI % ycount, j);
1198
+ tile.left = x;
1199
+ tile.top = y;
1200
+ if (baseLayer.layerType === 'Bing' || (bing && !isNullOrUndefined(baseLayer.urlTemplate) && baseLayer.urlTemplate !== '')) {
1201
+ const key: string = baseLayer.key;
1202
+ tile.src = bing.getBingMap(tile, key, baseLayer.bingMapType, userLang, bing.imageUrl, bing.subDomains);
1203
+ } else {
1204
+ tile.src = this.urlTemplate.replace('level', zoomLevel.toString()).replace('tileX', tile.x.toString())
1205
+ .replace('tileY', tile.y.toString());
1206
+ }
1207
+ this.tiles.push(tile);
1208
+ }
1209
+ }
1210
+ }
1211
+ }
1212
+ if (!isNullOrUndefined(zoomType)) {
1213
+ if (zoomType.indexOf('wheel') > 1) {
1214
+ this.animateToZoomX = (this.mapObject.availableSize.width / 2) - position.x - 10;
1215
+ this.animateToZoomY = -position.y;
1216
+ } else {
1217
+ this.animateToZoomX = -10;
1218
+ this.animateToZoomY = -(this.mapObject.availableSize.height / 2 + 11.5) + 10;
1219
+ }
1220
+ }
1221
+ const proxTiles: Tile[] = extend([], this.tiles, [], true) as Tile[];
1222
+ for (const layer of this.mapObject.layers) {
1223
+ if (!(layer.type === 'SubLayer' && layer.visible)) {
1224
+ continue;
1225
+ }
1226
+ if ((layer.layerType !== 'Geometry' && layer.layerType !== 'GoogleStaticMap') || (layer.layerType === 'Geometry' &&
1227
+ isNullOrUndefined(layer.shapeData) && !isNullOrUndefined(layer.urlTemplate) && layer.urlTemplate !== '')) {
1228
+ for (const baseTile of proxTiles) {
1229
+ const subtile: Tile = extend({}, baseTile, {}, true) as Tile;
1230
+ if (layer.layerType === 'Bing') {
1231
+ bing = new BingMap(this.mapObject);
1232
+ subtile.src = bing.getBingMap(subtile, layer.key, layer.bingMapType, userLang, bing.imageUrl, bing.subDomains);
1233
+ } else {
1234
+ subtile.src = layer.urlTemplate.replace('level', zoomLevel.toString()).replace('tileX', baseTile.x.toString())
1235
+ .replace('tileY', baseTile.y.toString());
1236
+ }
1237
+ this.tiles.push(subtile);
1238
+ }
1239
+ }
1240
+ }
1241
+ if (this.mapObject.previousScale !== this.mapObject.scale || this.mapObject.isReset) {
1242
+ this.arrangeTiles(zoomType, this.animateToZoomX, this.animateToZoomY);
1243
+ }
1244
+ }
1245
+
1246
+ public arrangeTiles(type: string, x: number, y: number): void {
1247
+ const element: HTMLElement = document.getElementById(this.mapObject.element.id + '_tile_parent');
1248
+ const element1: HTMLElement = document.getElementById(this.mapObject.element.id + '_tiles');
1249
+ let timeOut: number;
1250
+ if (!isNullOrUndefined(type) && type !== 'Pan') {
1251
+ this.tileAnimation(type, x, y);
1252
+ timeOut = this.mapObject.layersCollection[0].animationDuration;
1253
+ } else {
1254
+ timeOut = 0;
1255
+ }
1256
+ if (this.mapObject.layers[this.mapObject.baseLayerIndex].layerType === 'GoogleStaticMap') {
1257
+ this.renderGoogleMap(this.mapObject.layers[0].key, this.mapObject.staticMapZoom);
1258
+ } else {
1259
+ setTimeout(() => {
1260
+ if (element) {
1261
+ element.style.zIndex = '1';
1262
+ }
1263
+ if (element1) {
1264
+ element1.style.zIndex = '0';
1265
+ }
1266
+ let animateElement: HTMLElement;
1267
+ if (!document.getElementById(this.mapObject.element.id + '_animated_tiles') && element) {
1268
+ animateElement = createElement('div', { id: this.mapObject.element.id + '_animated_tiles' });
1269
+ element.appendChild(animateElement);
1270
+ } else {
1271
+ if (type !== 'Pan' && element1 && element) {
1272
+ element1.appendChild(element.children[0]);
1273
+ if (!this.mapObject.isAddLayer && !isNullOrUndefined(document.getElementById(this.mapObject.element.id + '_animated_tiles'))) {
1274
+ document.getElementById(this.mapObject.element.id + '_animated_tiles').id =
1275
+ this.mapObject.element.id + '_animated_tiles_old';
1276
+ }
1277
+ animateElement = createElement('div', { id: this.mapObject.element.id + '_animated_tiles' });
1278
+ element.appendChild(animateElement);
1279
+ } else {
1280
+ animateElement = element ? element.children[0] as HTMLElement : null;
1281
+ }
1282
+ }
1283
+ let id: number = 0;
1284
+ for (const tile of this.tiles) {
1285
+ const imgElement: HTMLElement = createElement('img');
1286
+ imgElement.setAttribute('height', '256px');
1287
+ imgElement.setAttribute('width', '256px');
1288
+ imgElement.setAttribute('src', tile.src);
1289
+ imgElement.setAttribute('alt', this.mapObject.getLocalizedLabel('ImageNotFound'));
1290
+ const mapId: string = this.mapObject.element.id;
1291
+ imgElement.onload = () => {
1292
+ if (document.getElementById(mapId + '_tile_' + id) && type === 'Pan') {
1293
+ removeElement(mapId + '_tile_' + id);
1294
+ }
1295
+ const child: HTMLElement = createElement('div', { id: mapId + '_tile_' + id });
1296
+ child.style.position = 'absolute';
1297
+ child.style.left = tile.left + 'px';
1298
+ child.style.top = tile.top + 'px';
1299
+ child.style.height = tile.height + 'px';
1300
+ child.style.width = tile.width + 'px';
1301
+ child.appendChild(imgElement);
1302
+ if (animateElement) {
1303
+ animateElement.appendChild(child);
1304
+ }
1305
+ id++;
1306
+ if (id === this.tiles.length && document.getElementById(this.mapObject.element.id + '_animated_tiles_old')) {
1307
+ removeElement(this.mapObject.element.id + '_animated_tiles_old');
1308
+ }
1309
+ };
1310
+ }
1311
+ }, timeOut);
1312
+ }
1313
+ }
1314
+
1315
+ /**
1316
+ * Animation for tile layers and hide the group element until the tile layer rendering
1317
+ *
1318
+ * @param {string} zoomType - Specifies the zoom type
1319
+ * @param {number} translateX - Specifies the x translate point
1320
+ * @param {number} translateY - Specifies the y translate point
1321
+ * @returns {void}
1322
+ */
1323
+ private tileAnimation(zoomType: string, translateX: number, translateY: number): void {
1324
+ const tileParent: HTMLElement = document.getElementById(this.mapObject.element.id + '_tile_parent');
1325
+ const animatedTiles: HTMLElement = document.getElementById(this.mapObject.element.id + '_animated_tiles');
1326
+ const tileElement: HTMLElement = document.getElementById(this.mapObject.element.id + '_tiles');
1327
+ let scaleValue: string = '2';
1328
+ if (zoomType.indexOf('ZoomOut') === 0 || zoomType === 'Reset') {
1329
+ tileElement.style.zIndex = '1';
1330
+ tileParent.style.zIndex = '0';
1331
+ while (tileElement.childElementCount >= 1) {
1332
+ tileElement.removeChild(tileElement.children[0]);
1333
+ }
1334
+ translateX = 0;
1335
+ translateY = document.getElementById(this.mapObject.element.id + '_tile_parent').getClientRects()[0].height / 4;
1336
+ scaleValue = zoomType.indexOf('ZoomOut') === 0 ? '0.5' : '0.2';
1337
+ }
1338
+ if (!isNullOrUndefined(animatedTiles)) {
1339
+ animatedTiles.style.transition = this.mapObject.layersCollection[0].animationDuration + 'ms';
1340
+ animatedTiles.style.transform = 'translate(' + translateX + 'px, ' + translateY + 'px) scale(' + scaleValue + ')';
1341
+ }
1342
+ }
1343
+
1344
+ /**
1345
+ * Static map rendering
1346
+ *
1347
+ * @param {string} apikey - Specifies the api key
1348
+ * @param {number} zoom - Specifies the zoom value
1349
+ * @returns {void}
1350
+ * @private
1351
+ */
1352
+ public renderGoogleMap(apikey: string, zoom: number): void {
1353
+ const map: Maps = this.mapObject;
1354
+ // zoom = this.mapObject.zoomSettings.shouldZoomInitially ? this.mapObject.markerZoomFactor : zoom;
1355
+ zoom = this.mapObject.tileZoomLevel;
1356
+ const totalSize: number = Math.pow(2, zoom) * 256;
1357
+ const x: number = (map.mapAreaRect.width / 2) - (totalSize / 2);
1358
+ const y: number = (map.mapAreaRect.height / 2) - (totalSize / 2);
1359
+ const centerPoint: Point = new Point(null, null);
1360
+ let diffX: number = 0; let diffY: number = 0;
1361
+ const position: MapLocation = convertTileLatLongToPoint(
1362
+ centerPoint, zoom, { x: x, y: y }, this.isMapCoordinates);
1363
+ if (map.zoomModule && map.zoomSettings.enable) {
1364
+ diffX = map.zoomModule.mouseDownLatLong['x'] - map.zoomModule.mouseMoveLatLong['x'];
1365
+ diffY = map.zoomModule.mouseDownLatLong['y'] - map.zoomModule.mouseMoveLatLong['y'];
1366
+ }
1367
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1368
+ const panLatLng: any = map.pointToLatLong(position.x - diffX, position.y - diffY);
1369
+ map.centerPosition.latitude = panLatLng['latitude'];
1370
+ map.centerPosition.longitude = panLatLng['longitude'];
1371
+ let mapWidth: number;
1372
+ let mapHeight: number;
1373
+ if (isNullOrUndefined(parseInt(map.width, 10))) {
1374
+ mapWidth = parseInt(map.width, 10) - 22;
1375
+ } else {
1376
+ mapWidth = Math.round(map.mapAreaRect.width);
1377
+ }
1378
+ if (isNullOrUndefined(parseInt(map.height, 10))) {
1379
+ mapHeight = parseInt(map.height, 10) - 22;
1380
+ } else {
1381
+ mapHeight = Math.round(map.mapAreaRect.height);
1382
+ }
1383
+ const eleWidth: number = mapWidth > 640 ? (mapWidth - 640) / 2 : 0;
1384
+ const eleHeight: number = mapHeight > 640 ? (mapHeight - 640) / 2 : 0;
1385
+ let center: string;
1386
+ const mapType: string = (map.layers[map.layers.length - 1].staticMapType).toString().toLowerCase();
1387
+ if (map.centerPosition.latitude && map.centerPosition.longitude) {
1388
+ center = map.centerPosition.latitude.toString() + ',' + map.centerPosition.longitude.toString();
1389
+ } else {
1390
+ center = '0,0';
1391
+ }
1392
+ const staticMapString: string = 'https://maps.googleapis.com/maps/api/staticmap?size=' + mapWidth + 'x' + mapHeight +
1393
+ '&zoom=' + zoom + '&center=' + center + '&maptype=' + mapType + '&key=' + apikey;
1394
+ document.getElementById(this.mapObject.element.id + '_tile_parent').innerHTML
1395
+ = '<div id="' + this.mapObject.element.id + '_StaticGoogleMap"' + 'style="position:absolute; left:' + eleWidth + 'px; top:'
1396
+ + eleHeight + 'px"><img src="' + staticMapString + '"' + 'alt="' + this.mapObject.getLocalizedLabel('ImageNotFound') + '"></div>';
1397
+ }
1398
+
1399
+ /**
1400
+ * To find the tile translate point
1401
+ *
1402
+ * @param {number} factorX - Specifies the x factor
1403
+ * @param {number} factorY - Specifies the x factor
1404
+ * @param {MapLocation} centerPosition - Specifies the map location
1405
+ * @returns {Point} - Returns point values
1406
+ */
1407
+ private panTileMap(factorX: number, factorY: number, centerPosition: MapLocation): Point {
1408
+ if (this.mapObject.tileZoomLevel <= this.mapObject.tileZoomScale && this.mapObject.initialCheck) {
1409
+ this.mapObject.tileZoomLevel = this.mapObject.tileZoomScale;
1410
+ }
1411
+ const level: number = this.mapObject.tileZoomLevel;
1412
+ let padding: number = this.mapObject.layers[this.mapObject.layers.length - 1].layerType !== 'GoogleStaticMap' ?
1413
+ 20 : 0;
1414
+ let x: number; let y: number;
1415
+ const totalSize: number = Math.pow(2, level) * 256;
1416
+ x = (factorX / 2) - (totalSize / 2);
1417
+ y = (factorY / 2) - (totalSize / 2);
1418
+ const position: MapLocation = convertTileLatLongToPoint(
1419
+ centerPosition, level, { x: x, y: y }, this.isMapCoordinates);
1420
+ padding = this.mapObject.zoomNotApplied ? 0 : padding;
1421
+ x -= position.x - (factorX / 2);
1422
+ y = (y - (position.y - (factorY / 2))) + padding;
1423
+ this.mapObject.scale = Math.pow(2, level - 1);
1424
+ if ((isNullOrUndefined(this.mapObject.tileTranslatePoint) || (this.mapObject.tileTranslatePoint.y === 0 &&
1425
+ this.mapObject.tileTranslatePoint.x === 0)) || (isNullOrUndefined(this.mapObject.previousTileWidth) ||
1426
+ isNullOrUndefined(this.mapObject.previousTileHeight))) {
1427
+ this.mapObject.previousTileWidth = factorX;
1428
+ this.mapObject.previousTileHeight = factorY;
1429
+ }
1430
+ if (!isNullOrUndefined(this.mapObject.tileTranslatePoint) && (isNullOrUndefined(centerPosition.x)) &&
1431
+ (this.mapObject.zoomSettings.zoomFactor === 1 ||
1432
+ this.mapObject.zoomSettings.zoomFactor !== level || !this.mapObject.defaultState)) {
1433
+ if ((factorX !== this.mapObject.previousTileWidth || factorY !== this.mapObject.previousTileHeight) ) {
1434
+ const xdiff: number = x - ((this.mapObject.previousTileWidth / 2) - (totalSize / 2));
1435
+ const ydiff: number = y - ((this.mapObject.previousTileHeight / 2) - (totalSize / 2) + padding);
1436
+ this.mapObject.tileTranslatePoint.x = this.mapObject.tileTranslatePoint.x + xdiff;
1437
+ this.mapObject.tileTranslatePoint.y = this.mapObject.tileTranslatePoint.y + ydiff;
1438
+ }
1439
+ }
1440
+ if (!isNullOrUndefined(this.mapObject.tileTranslatePoint) && !this.mapObject.zoomNotApplied) {
1441
+ if (this.mapObject.tileTranslatePoint.x !== 0 && this.mapObject.tileTranslatePoint.x !== x
1442
+ && !this.mapObject.centerPositionChanged) {
1443
+ x = this.mapObject.tileTranslatePoint.x;
1444
+ }
1445
+ if (this.mapObject.tileTranslatePoint.y !== 0 && this.mapObject.tileTranslatePoint.y !== y
1446
+ && !this.mapObject.centerPositionChanged) {
1447
+ y = this.mapObject.tileTranslatePoint.y;
1448
+ }
1449
+ }
1450
+ this.mapObject.translatePoint = new Point(
1451
+ (x - (0.01 * this.mapObject.zoomSettings.zoomFactor)) / this.mapObject.scale,
1452
+ (y - (0.01 * this.mapObject.zoomSettings.zoomFactor)) / this.mapObject.scale
1453
+ );
1454
+ this.mapObject.previousTileWidth = factorX;
1455
+ this.mapObject.previousTileHeight = factorY;
1456
+ return new Point(x, y);
1457
+ }
1458
+
1459
+ /**
1460
+ * @returns {void}
1461
+ * @private
1462
+ */
1463
+ public destroy(): void {
1464
+ this.mapObject = null;
1465
+ this.groupElements = [];
1466
+ this.layerObject = null;
1467
+ this.currentLayer = null;
1468
+ this.rectBounds = null;
1469
+ this.tiles = [];
1470
+ this.clipRectElement = null;
1471
+ this.tileSvgObject = null;
1472
+ this.ajaxModule = null;
1473
+ this.ajaxResponse = [];
1474
+ this.layerGroup = null;
1475
+ if (!isNullOrUndefined(this.bing)) {
1476
+ this.bing.destroy();
1477
+ }
1478
+ this.bing = null;
1479
+ }
1480
+ }