@syncfusion/ej2-maps 30.1.37 → 31.1.17

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