@syncfusion/ej2-maps 31.1.17 → 31.2.12

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 (67) hide show
  1. package/README.md +11 -2
  2. package/dist/ej2-maps.min.js +3 -3
  3. package/dist/ej2-maps.umd.min.js +3 -3
  4. package/dist/ej2-maps.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-maps.es2015.js +84 -53
  6. package/dist/es6/ej2-maps.es2015.js.map +1 -1
  7. package/dist/es6/ej2-maps.es5.js +87 -56
  8. package/dist/es6/ej2-maps.es5.js.map +1 -1
  9. package/dist/global/ej2-maps.min.js +3 -3
  10. package/dist/global/ej2-maps.min.js.map +1 -1
  11. package/dist/global/index.d.ts +2 -2
  12. package/package.json +18 -53
  13. package/src/maps/layers/layer-panel.js +86 -55
  14. package/dist/ts/index.d.ts +0 -4
  15. package/dist/ts/index.ts +0 -4
  16. package/dist/ts/maps/index.d.ts +0 -28
  17. package/dist/ts/maps/index.ts +0 -28
  18. package/dist/ts/maps/layers/bing-map.d.ts +0 -21
  19. package/dist/ts/maps/layers/bing-map.ts +0 -51
  20. package/dist/ts/maps/layers/bubble.d.ts +0 -77
  21. package/dist/ts/maps/layers/bubble.ts +0 -304
  22. package/dist/ts/maps/layers/color-mapping.d.ts +0 -36
  23. package/dist/ts/maps/layers/color-mapping.ts +0 -230
  24. package/dist/ts/maps/layers/data-label.d.ts +0 -45
  25. package/dist/ts/maps/layers/data-label.ts +0 -457
  26. package/dist/ts/maps/layers/layer-panel.d.ts +0 -144
  27. package/dist/ts/maps/layers/layer-panel.ts +0 -1455
  28. package/dist/ts/maps/layers/legend.d.ts +0 -173
  29. package/dist/ts/maps/layers/legend.ts +0 -2465
  30. package/dist/ts/maps/layers/marker.d.ts +0 -105
  31. package/dist/ts/maps/layers/marker.ts +0 -632
  32. package/dist/ts/maps/layers/navigation-selected-line.d.ts +0 -33
  33. package/dist/ts/maps/layers/navigation-selected-line.ts +0 -171
  34. package/dist/ts/maps/layers/polygon.d.ts +0 -30
  35. package/dist/ts/maps/layers/polygon.ts +0 -68
  36. package/dist/ts/maps/maps-model.d.ts +0 -409
  37. package/dist/ts/maps/maps.d.ts +0 -1247
  38. package/dist/ts/maps/maps.ts +0 -3416
  39. package/dist/ts/maps/model/base-model.d.ts +0 -2107
  40. package/dist/ts/maps/model/base.d.ts +0 -1840
  41. package/dist/ts/maps/model/base.ts +0 -2257
  42. package/dist/ts/maps/model/constants.d.ts +0 -225
  43. package/dist/ts/maps/model/constants.ts +0 -226
  44. package/dist/ts/maps/model/export-image.d.ts +0 -39
  45. package/dist/ts/maps/model/export-image.ts +0 -194
  46. package/dist/ts/maps/model/export-pdf.d.ts +0 -40
  47. package/dist/ts/maps/model/export-pdf.ts +0 -183
  48. package/dist/ts/maps/model/interface.d.ts +0 -892
  49. package/dist/ts/maps/model/interface.ts +0 -929
  50. package/dist/ts/maps/model/print.d.ts +0 -45
  51. package/dist/ts/maps/model/print.ts +0 -125
  52. package/dist/ts/maps/model/theme.d.ts +0 -98
  53. package/dist/ts/maps/model/theme.ts +0 -919
  54. package/dist/ts/maps/user-interaction/annotation.d.ts +0 -27
  55. package/dist/ts/maps/user-interaction/annotation.ts +0 -133
  56. package/dist/ts/maps/user-interaction/highlight.d.ts +0 -63
  57. package/dist/ts/maps/user-interaction/highlight.ts +0 -272
  58. package/dist/ts/maps/user-interaction/selection.d.ts +0 -85
  59. package/dist/ts/maps/user-interaction/selection.ts +0 -342
  60. package/dist/ts/maps/user-interaction/tooltip.d.ts +0 -78
  61. package/dist/ts/maps/user-interaction/tooltip.ts +0 -500
  62. package/dist/ts/maps/user-interaction/zoom.d.ts +0 -334
  63. package/dist/ts/maps/user-interaction/zoom.ts +0 -2523
  64. package/dist/ts/maps/utils/enum.d.ts +0 -328
  65. package/dist/ts/maps/utils/enum.ts +0 -343
  66. package/dist/ts/maps/utils/helper.d.ts +0 -1318
  67. package/dist/ts/maps/utils/helper.ts +0 -3811
@@ -1,457 +0,0 @@
1
- import { Maps } from '../../index';
2
- import {
3
- findMidPointOfPolygon, Rect, filter, getTemplateFunction, getZoomTranslate,
4
- getTranslate, RectOption, convertElementFromLabel,
5
- Point, TextOption, renderTextElement, MapLocation, textTrim, Size, Internalize, measureTextElement
6
- } from '../utils/helper';
7
- import { isNullOrUndefined, AnimationOptions, Animation, animationMode } from '@syncfusion/ej2-base';
8
- import { FontModel, DataLabelSettingsModel, ILabelRenderingEventArgs, LayerSettings } from '../index';
9
- import { dataLabelRendering } from '../model/constants';
10
-
11
- /**
12
- * DataLabel Module used to render the maps datalabel
13
- */
14
- export class DataLabel {
15
- private maps: Maps;
16
- /**
17
- * Datalabel collections
18
- *
19
- * @private
20
- */
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- public dataLabelCollections: any[];
23
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
- private value: any = { rightWidth: 0, leftWidth: 0, heightTop: 0, heightBottom: 0 };
25
- constructor(maps: Maps) {
26
- this.maps = maps;
27
- this.dataLabelCollections = [];
28
- }
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- private getDataLabel(dataSource: any[], labelPath: string, shapeName: string, shapeDataPath: string): any {
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- let text: any; let shapeNameValue : string;
33
- for (let i: number = 0; i < (isNullOrUndefined(dataSource) ? 0 : dataSource.length); i++) {
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- const data: any = dataSource[i as number];
36
- const dataShapePathValue: string = !isNullOrUndefined(data[shapeDataPath as string]) && isNaN(data[shapeDataPath as string]) &&
37
- typeof data[shapeDataPath as string] === 'string' ? data[shapeDataPath as string].toLowerCase() : data[shapeDataPath as string];
38
- shapeName = !isNullOrUndefined(shapeName) && typeof shapeName === 'string' ? shapeName.toString() : shapeName;
39
- shapeNameValue = !isNullOrUndefined(shapeName) && typeof shapeName === 'string' ? shapeName.toLowerCase() : shapeName;
40
- if ((dataShapePathValue) === shapeNameValue) {
41
- text = data;
42
- break;
43
- }
44
- }
45
- return text;
46
- }
47
- /**
48
- * To render label for maps.
49
- *
50
- * @param {LayerSettings} layer - Specifies the layer settings
51
- * @param {number} layerIndex - Specifies the layer index.
52
- * @param {object} shape - Specifies the shape.
53
- * @param {any[]} layerData - Specifies the layer data.
54
- * @param {Element} group Specifies the element.
55
- * @param {HTMLElement} labelTemplateElement - Specifies the template element.
56
- * @param {number} index - Specifies the index number.
57
- * @param {any[]} intersect - Specifies the intersect.
58
- * @returns {void}
59
- * @private
60
- */
61
- public renderLabel(
62
- layer: LayerSettings, layerIndex: number, shape: object,
63
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- layerData: any[], group: Element, labelTemplateElement: HTMLElement, index: number, intersect: any[]
65
- ): void {
66
- const dataLabel: DataLabelSettingsModel = layer.dataLabelSettings;
67
- const style: FontModel = layer.dataLabelSettings.textStyle;
68
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
- let templateFn: any;
70
- let options: TextOption;
71
- const dataLabelSettings: DataLabelSettingsModel = layer.dataLabelSettings;
72
- const labelpath: string = layer.dataLabelSettings.labelPath;
73
- let shapePoint: [MapLocation[]] = [[]];
74
- let midIndex: number = 0;
75
- let pointsLength: number = 0;
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const shapeData: any = shape;
78
- let element: Element;
79
- let rect: Element;
80
- let text: string = '';
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- let datasrcObj: any;
83
- let currentLength: number = 0; let oldIndex : number;
84
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
- let location: any;
86
- let sublayerIndexLabel : boolean = false;
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- const shapeProperties: any = shape['properties'];
89
- const labelId: string = this.maps.element.id + '_LayerIndex_' + layerIndex + '_shapeIndex_' + index + '_LabelIndex_' + index;
90
- const textLocation: Point = new Point(0, 0);
91
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
- const shapes: any = layerData[index as number]; let locationX: any; let locationY: any;
93
- style.fontFamily = this.maps.theme.toLowerCase() !== 'material' ? this.maps.themeStyle.labelFontFamily : style.fontFamily;
94
- style.fontWeight = style.fontWeight || this.maps.themeStyle.fontWeight;
95
- style.size = style.size || this.maps.themeStyle.fontSize;
96
- shape = !isNullOrUndefined(shapes) ? shapes['property'] : null;
97
- const properties: string[] = (Object.prototype.toString.call(layer.shapePropertyPath) === '[object Array]' ?
98
- layer.shapePropertyPath : [layer.shapePropertyPath]) as string[];
99
- let propertyPath: string; const isPoint : boolean = false;
100
- const animate: boolean = (layer.animationDuration !== 0 || animationMode === 'Enable') || isNullOrUndefined(this.maps.zoomModule);
101
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102
- const translate: any = (this.maps.isTileMap) ? new Object() : ((this.maps.zoomSettings.zoomFactor > 1 &&
103
- !isNullOrUndefined(this.maps.zoomModule)) ? getZoomTranslate(this.maps, layer, animate) :
104
- getTranslate(this.maps, layer, animate));
105
- const scale: number = (this.maps.isTileMap) ? this.maps.scale : translate['scale'];
106
- const transPoint: Point = (this.maps.isTileMap) ? this.maps.translatePoint : translate['location'] as Point;
107
- const zoomTransPoint : Point = this.maps.zoomTranslatePoint; let shapeWidth: number;
108
- const scaleZoomValue : number = !isNullOrUndefined(this.maps.scale) ? Math.floor(this.maps.scale) : 1;
109
- const zoomLabelsPosition : boolean = this.maps.zoomSettings.enable ? !isNullOrUndefined(this.maps.zoomShapeCollection) &&
110
- this.maps.zoomShapeCollection.length > 0 && !this.maps.isAddLayer : this.maps.zoomSettings.enable; this.maps.translateType = 'labels';
111
- for (let j: number = 0; j < properties.length; j++) {
112
- if (shapeProperties[properties[j as number]]) {
113
- propertyPath = properties[j as number];
114
- datasrcObj = this.getDataLabel(
115
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
116
- layer.dataSource as any[], layer.shapeDataPath, shapeData['properties'][propertyPath as string], layer.shapeDataPath);
117
- if (datasrcObj) {
118
- break;
119
- }
120
- }
121
- }
122
- datasrcObj = this.getDataLabel(
123
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
124
- layer.dataSource as any[], layer.shapeDataPath, shapeData['properties'][propertyPath as string], layer.shapeDataPath);
125
- if (!isNullOrUndefined(shapes) && !isNullOrUndefined(shapes['property'])) {
126
- shapePoint = [[]];
127
- if (!layerData[index as number]['_isMultiPolygon'] && layerData[index as number]['type'] !== 'Point' && layerData[index as number]['type'] !== 'MultiPoint') {
128
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
- shapePoint.push(this.getPoint(layerData[index as number] as any[], []));
130
- currentLength = shapePoint[shapePoint.length - 1].length;
131
- if (pointsLength < currentLength) {
132
- pointsLength = currentLength;
133
- midIndex = shapePoint.length - 1;
134
- }
135
- } else if (layerData[index as number]['type'] !== 'Point' && layerData[index as number]['type'] !== 'MultiPoint') {
136
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
- const layer: any[] = <any[]>layerData[index as number];
138
- for (let j: number = 0; j < layer.length; j++) {
139
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
140
- shapePoint.push(this.getPoint(layer[j as number] as any[], []));
141
- currentLength = shapePoint[shapePoint.length - 1].length;
142
- if (pointsLength < currentLength) {
143
- pointsLength = currentLength;
144
- midIndex = shapePoint.length - 1;
145
- }
146
- }
147
- }
148
- }
149
- text = (!isNullOrUndefined(datasrcObj)) ? !isNullOrUndefined(datasrcObj[labelpath as string]) ?
150
- datasrcObj[labelpath as string].toString() : shapeData['properties'][labelpath as string] || datasrcObj[layer.shapeDataPath] : shapeData['properties'][labelpath as string];
151
- if ((Object.prototype.toString.call(layer.shapePropertyPath) === '[object Array]') &&
152
- (isNullOrUndefined(text) && (!isNullOrUndefined(layer.dataSource) && layer.dataSource['length'] === 0))) {
153
- for (let l: number = 0; l < layer.shapePropertyPath.length; l++) {
154
- if (shapeData['properties'][layer.shapePropertyPath[l as number]]) {
155
- text = shapeData['properties'][layer.shapePropertyPath[l as number]];
156
- break;
157
- }
158
- }
159
- }
160
- if (isNullOrUndefined(text) && (layer.dataLabelSettings.template !== '' && layer.dataSource['length'] === 0)) {
161
- text = shapeData['properties'][layer.shapePropertyPath as string];
162
- }
163
- if (isNullOrUndefined(text) && (!isNullOrUndefined(layer.dataSource) && layer.dataSource['length'] > 0)) {
164
- text = '';
165
- }
166
- const dataLabelText : string = text;
167
- const projectionType : string = this.maps.projectionType;
168
- if (isPoint) {
169
- location = {
170
- x: shapePoint[midIndex as number][index as number]['x'], y: shapePoint[midIndex as number][index as number]['y'],
171
- rightMin: 0, rightMax: 0, leftMin: 0, leftMax: 0,
172
- points: shapePoint[midIndex as number][index as number], topMax: 0, topMin: 0,
173
- bottomMax: 0, bottomMin: 0, height: 0
174
- };
175
- } else {
176
- location = findMidPointOfPolygon(shapePoint[midIndex as number], projectionType, layer.geometryType);
177
- }
178
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
179
- const firstLevelMapLocation : any = location;
180
- if (!isNullOrUndefined(text) && !isNullOrUndefined(location)) {
181
- if (zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied && dataLabel.template === '') {
182
- if (layerIndex > 0){
183
- for (let k : number = 0; k < this.maps.zoomLabelPositions.length; k++){
184
- if (this.maps.zoomLabelPositions[k as number]['dataLabelText'] === text) {
185
- oldIndex = index;
186
- index = k;
187
- sublayerIndexLabel = true;
188
- break;
189
- }
190
- }
191
- }
192
- locationX = location['x'];
193
- locationY = location['y'];
194
- location['x'] = ((location['x'] + zoomTransPoint['x']) * scale);
195
- location['y'] = ((location['y'] + zoomTransPoint['y']) * scale);
196
- }
197
- location['y'] = (this.maps.projectionType === 'Mercator') || layer.geometryType === 'Normal' ? location['y'] : (-location['y']);
198
- if (!isNullOrUndefined(this.maps.format) && !isNaN(Number(text)) && !isNaN(parseFloat(text))) {
199
- if (this.maps.useGroupingSeparator) {
200
- text = Internalize(this.maps, parseFloat(text));
201
- if (!isNullOrUndefined(datasrcObj)) {
202
- datasrcObj[labelpath as string] = text;
203
- }
204
- }
205
- }
206
- const eventargs: ILabelRenderingEventArgs = {
207
- name: dataLabelRendering, maps: this.maps, cancel: false, border: { color: dataLabel.border.color,
208
- width: dataLabel.border.width, opacity: dataLabel.border.opacity }, datalabel: dataLabel,
209
- fill: dataLabel.fill, template: dataLabel.template, text: text, offsetX: 0, offsetY: 0
210
- };
211
- this.maps.trigger('dataLabelRendering', eventargs, (labelArgs: ILabelRenderingEventArgs) => {
212
- if (eventargs.cancel) {
213
- return;
214
- }
215
- let position: MapLocation[] = [];
216
- let width: number = zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied
217
- && this.maps.zoomShapeCollection.length > index ? (this.maps.dataLabelShape[index as number]) * scale :
218
- (location['rightMax']['x'] - location['leftMax']['x']) * scale;
219
- if (!isNullOrUndefined(this.maps.dataLabelShape) && !this.maps.isReset){
220
- shapeWidth = firstLevelMapLocation['rightMax']['x'] - firstLevelMapLocation['leftMax']['x'];
221
- this.maps.dataLabelShape.push(shapeWidth);
222
- }
223
- if (eventargs.text !== text && !eventargs.cancel){
224
- text = eventargs.text;
225
- }
226
- const textSize: Size = measureTextElement(text, style);
227
- let trimmedLable: string = text;
228
- let elementSize: Size = textSize;
229
- const startY: number = location['y'] - textSize['height'] / 2;
230
- const endY: number = location['y'] + textSize['height'] / 2;
231
- const start: number = ((location['y'] + transPoint['y']) * scale) - textSize['height'] / 2;
232
- const end: number = ((location['y'] + transPoint['y']) * scale) + textSize['height'] / 2;
233
- position = filter(shapePoint[midIndex as number], startY, endY);
234
- if (!isPoint && position.length > 5 && (shapeData['geometry']['type'] !== 'MultiPolygon') &&
235
- (shapeData['type'] !== 'MultiPolygon')) {
236
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
237
- const location1: any = findMidPointOfPolygon(position, projectionType, layer.geometryType);
238
- if (zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied && eventargs.template === '') {
239
- location1['x'] = ((this.maps.zoomLabelPositions[index as number]['location']['x'] + zoomTransPoint['x']) * scale);
240
- location1['y'] = ((this.maps.zoomLabelPositions[index as number]['location']['y'] + zoomTransPoint['y']) * scale);
241
- }
242
- locationX = location1['x'];
243
- location['x'] = location1['x'];
244
- width = zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied
245
- && this.maps.zoomShapeCollection.length > index ? (this.maps.dataLabelShape[index as number]) * scale :
246
- ((location1['rightMax']['x'] - location1['leftMax']['x']) * scale) > 0 ?
247
- ((location1['rightMax']['x'] - location1['leftMax']['x']) * scale) : width;
248
- }
249
- const xpositionEnds: number = ((location['x'] + transPoint['x']) * scale) + textSize['width'] / 2;
250
- const xpositionStart: number = ((location['x'] + transPoint['x']) * scale) - textSize['width'] / 2;
251
- this.value[index as number] = { rightWidth: xpositionEnds, leftWidth: xpositionStart, heightTop: start, heightBottom: end };
252
- let labelElement: HTMLElement;
253
- if (eventargs.template !== '') {
254
- templateFn = getTemplateFunction(eventargs.template, this.maps);
255
- const templateElement: Element = templateFn ? templateFn(!isNullOrUndefined(datasrcObj) ?
256
- datasrcObj : shapeData['properties'], this.maps, eventargs.template, this.maps.element.id + '_LabelTemplate', false) : document.createElement('div');
257
- templateElement.innerHTML = !templateFn ? eventargs.template as string : '';
258
- labelElement = <HTMLElement>convertElementFromLabel(
259
- templateElement, labelId, !isNullOrUndefined(datasrcObj) ? datasrcObj : shapeData['properties']);
260
- if (this.maps.isTileMap) {
261
- labelElement.style.left = (((location['x'] + transPoint['x']) * scale) - (textSize['width'] / 2)) + 'px';
262
- labelElement.style.top = (((location['y'] + transPoint['y']) * scale) - textSize['height']) + 'px';
263
- } else {
264
- labelElement.style.left = ((Math.abs(this.maps.baseMapRectBounds['min']['x'] - location['x'])) * scale) + labelArgs.offsetX + 'px';
265
- labelElement.style.top = ((Math.abs(this.maps.baseMapRectBounds['min']['y'] - location['y'])) * scale) + labelArgs.offsetY + 'px';
266
- }
267
- labelTemplateElement.appendChild(labelElement);
268
- } else {
269
- const smartLabelMode: string = !isNullOrUndefined(dataLabelSettings.smartLabelMode) ? dataLabelSettings.smartLabelMode.toString() : 'None';
270
- if (smartLabelMode === 'Trim') {
271
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
272
- const textType: any = typeof text === 'number' ? (text as any).toString() : text;
273
- trimmedLable = textTrim(width, textType, style, null, true);
274
- elementSize = measureTextElement(trimmedLable, style);
275
- options = new TextOption(labelId, textLocation.x, textLocation.y, 'middle', trimmedLable, '', '');
276
- }
277
- if (smartLabelMode === 'None') {
278
- options = new TextOption(labelId, (textLocation.x), textLocation.y, 'middle', text, '', '');
279
- }
280
- if (smartLabelMode === 'Hide') {
281
- text = (width >= textSize['width']) ? text : '';
282
- options = new TextOption(labelId, (textLocation.x), (textLocation.y), 'middle', text, '', '');
283
- }
284
- if (!isNullOrUndefined(options)) {
285
- text = options['text'] as string;
286
- }
287
- const intersectionAction: string = !isNullOrUndefined(dataLabelSettings.intersectionAction) ? dataLabelSettings.intersectionAction.toString() : 'None';
288
- if (intersectionAction === 'Hide') {
289
- for (let i: number = 0; i < intersect.length; i++) {
290
- if (!isNullOrUndefined(intersect[i as number])) {
291
- if (!(this.value[index as number]['leftWidth'] > intersect[i as number]['rightWidth']
292
- || this.value[index as number]['rightWidth'] < intersect[i as number]['leftWidth']
293
- || this.value[index as number]['heightTop'] > intersect[i as number]['heightBottom']
294
- || this.value[index as number]['heightBottom'] < intersect[i as number]['heightTop'])) {
295
- text = '';
296
- break;
297
- }
298
- }
299
- }
300
- intersect.push(this.value[index as number]);
301
- options = new TextOption(labelId, textLocation.x, textLocation.y, 'middle', text, '', '');
302
- }
303
- let difference: number;
304
- if (intersectionAction === 'Trim') {
305
- for (let j: number = 0; j < intersect.length; j++) {
306
- if (!isNullOrUndefined(intersect[j as number])) {
307
- if (intersect[j as number]['rightWidth'] < this.value[index as number]['leftWidth']
308
- || intersect[j as number]['leftWidth'] > this.value[index as number]['rightWidth']
309
- || intersect[j as number]['heightBottom'] < this.value[index as number]['heightTop']
310
- || intersect[j as number]['heightTop'] > this.value[index as number]['heightBottom']) {
311
- trimmedLable = text;
312
- difference = 0;
313
- } else {
314
- if (this.value[index as number]['leftWidth'] > intersect[j as number]['leftWidth']) {
315
- width = intersect[j as number]['rightWidth'] - this.value[index as number]['leftWidth'];
316
- difference = width - (this.value[index as number]['rightWidth'] - this.value[index as number]['leftWidth']);
317
- trimmedLable = textTrim(difference, text, style, null, true);
318
- break;
319
- }
320
- if (this.value[index as number]['leftWidth'] < intersect[j as number]['leftWidth']) {
321
- width = this.value[index as number]['rightWidth'] - intersect[j as number]['leftWidth'];
322
- difference = Math.abs(width - (this.value[index as number]['rightWidth'] - this.value[index as number]['leftWidth']));
323
- trimmedLable = textTrim(difference, text, style, null, true);
324
- break;
325
- }
326
- }
327
- }
328
- }
329
- elementSize = measureTextElement(trimmedLable, style);
330
- intersect.push(this.value[index as number]);
331
- options = new TextOption(labelId, textLocation.x, (textLocation.y), 'middle', trimmedLable, '', '');
332
- }
333
- if (intersectionAction === 'None') {
334
- options = new TextOption(labelId, (textLocation.x), (textLocation.y), 'middle', text, '', '');
335
- }
336
- if (trimmedLable.length > 1) {
337
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
338
- const border: any = eventargs.border;
339
- if (border['width'] > 1) {
340
- const fill: string = eventargs.fill;
341
- const opacity: number = dataLabelSettings.opacity;
342
- const rx: number = dataLabelSettings.rx;
343
- const ry: number = dataLabelSettings.ry;
344
- let x : number ; let y : number; const padding : number = 5;
345
- if (zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied) {
346
- x = ((location['x'] ) ) - textSize['width'] / 2;
347
- y = ((location['y'] ) ) - textSize['height'] / 2 - padding;
348
- } else {
349
- x = ((location['x'] + transPoint['x']) * scale) - textSize['width'] / 2;
350
- y = ((location['y'] + transPoint['y'] ) * scale) - textSize['height'] / 2;
351
- }
352
- border.opacity = isNullOrUndefined(border.opacity) ? opacity : border.opacity;
353
- const rectOptions: RectOption = new RectOption(
354
- this.maps.element.id + '_LayerIndex_' + layerIndex + '_shapeIndex_' + index + '_rectIndex_' + index,
355
- fill, border, opacity, new Rect((x + labelArgs.offsetX), (y + labelArgs.offsetY), textSize['width'], textSize['height']), rx, ry
356
- );
357
- rect = this.maps.renderer.drawRectangle(rectOptions) as SVGRectElement;
358
- rect.setAttribute('visibility', layer.dataLabelSettings.animationDuration > 0 || animationMode === 'Enable' ? 'hidden' : 'visibile');
359
- group.appendChild(rect);
360
- }
361
- }
362
- element = renderTextElement(options, style, style.color || this.maps.themeStyle.dataLabelFontColor, group);
363
- element.setAttribute('aria-label', text);
364
- element.setAttribute('role', 'region');
365
- element.setAttribute('visibility', layer.dataLabelSettings.animationDuration > 0 || animationMode === 'Enable' ? 'hidden' : 'visibile');
366
- if (zoomLabelsPosition && scaleZoomValue > 1 && !this.maps.zoomNotApplied){
367
- element.setAttribute('transform', 'translate( ' + ((location['x'] + labelArgs.offsetX) ) + ' '
368
- + (((location['y'] + labelArgs.offsetY) ) ) + ' )');
369
- location['x'] = locationX;
370
- location['y'] = locationY;
371
- } else {
372
- element.setAttribute('transform', 'translate( ' + (((location['x'] + transPoint.x) * scale) + labelArgs.offsetX) + ' '
373
- + ((((location['y'] + transPoint.y) * scale) + (elementSize.height / 2)) + labelArgs.offsetY) + ' )');
374
- }
375
- group.appendChild(element);
376
- }
377
- this.dataLabelCollections.push({
378
- location: { x: location['x'] + labelArgs.offsetX, y: location['y'] + labelArgs.offsetY },
379
- element: isNullOrUndefined(labelElement) ? element : labelElement,
380
- layerIndex: layerIndex,
381
- shapeIndex: sublayerIndexLabel ? oldIndex : index,
382
- labelIndex: sublayerIndexLabel ? oldIndex : index,
383
- dataLabelText: dataLabelText
384
- });
385
- if (labelTemplateElement.childElementCount > 0 && !this.maps.element.contains(labelTemplateElement)) {
386
- document.getElementById(this.maps.element.id + '_Secondary_Element').appendChild(labelTemplateElement);
387
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
388
- (this.maps as any).renderReactTemplates();
389
- }
390
- if (layer.dataLabelSettings.animationDuration > 0 || animationMode === 'Enable') {
391
- if (!isNullOrUndefined(element)) {
392
- this.datalabelAnimate(element as HTMLElement, dataLabelSettings.animationDuration, style.opacity, false);
393
- if (!isNullOrUndefined(rect)) {
394
- this.datalabelAnimate(rect as HTMLElement, dataLabelSettings.animationDuration,
395
- dataLabelSettings.opacity, true);
396
- }
397
- }
398
- }
399
- });
400
- }
401
- }
402
-
403
- private datalabelAnimate(element: HTMLElement, duration: number, opacity: number, isRect: boolean): void {
404
- let height: number = 0;
405
- new Animation({}).animate(<HTMLElement>element, {
406
- duration: (duration === 0 && animationMode === 'Enable') ? 1000 : duration,
407
- delay: 0,
408
- progress: (args: AnimationOptions) => {
409
- if (args.timeStamp > args.delay) {
410
- height = ((args.timeStamp - args.delay) / args.duration);
411
- element.setAttribute('style', 'user-select: none; visibility: visible;');
412
- element.setAttribute(isRect ? 'fill-opacity' : 'opacity', (opacity * height).toString());
413
- }
414
- },
415
- end: () => {
416
- element.style.visibility = 'visible';
417
- element.setAttribute(isRect ? 'fill-opacity' : 'opacity', opacity.toString());
418
- }
419
- });
420
- }
421
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
422
- private getPoint(shapes: any[], points: MapLocation[]): MapLocation[] {
423
- if (shapes['type'] === 'MultiLineString') {
424
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
425
- Array.prototype.forEach.call(shapes, (current: any) => {
426
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
427
- Array.prototype.forEach.call(current, (shape: any) => {
428
- points.push(new Point(shape['point']['x'], shape['point']['y']));
429
- });
430
- });
431
- } else {
432
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
433
- Array.prototype.forEach.call(shapes, (current: any) => {
434
- points.push(new Point(current['point']['x'], current['point']['y']));
435
- });
436
- }
437
- return points;
438
- }
439
- /**
440
- * Get module name.
441
- *
442
- * @returns {string} - Returns the module name.
443
- */
444
- protected getModuleName(): string {
445
- return 'DataLabel';
446
- }
447
-
448
- /**
449
- * @returns {void}
450
- * @private
451
- */
452
- public destroy(): void {
453
- this.dataLabelCollections = [];
454
- this.value = null;
455
- this.maps = null;
456
- }
457
- }
@@ -1,144 +0,0 @@
1
- import { Maps } from '../../maps/maps';
2
- import { Point } from '../utils/helper';
3
- import { LayerSettings, Tile } from '../model/base';
4
- import { BingMap } from './bing-map';
5
- /**
6
- * To calculate and render the shape layer
7
- */
8
- export declare class LayerPanel {
9
- private mapObject;
10
- currentFactor: number;
11
- private groupElements;
12
- private layerObject;
13
- private currentLayer;
14
- private rectBounds;
15
- tiles: Tile[];
16
- private clipRectElement;
17
- private urlTemplate;
18
- private isMapCoordinates;
19
- private tileSvgObject;
20
- private ajaxModule;
21
- private ajaxResponse;
22
- private bing;
23
- private animateToZoomX;
24
- private animateToZoomY;
25
- horizontalPan: boolean;
26
- horizontalPanXCount: number;
27
- layerGroup: Element;
28
- constructor(map: Maps);
29
- measureLayerPanel(): void;
30
- /**
31
- * Tile rendering
32
- *
33
- * @param {LayerPanel} panel - Specifies the layer panel.
34
- * @param {LayerSettings} layer - Specifies the layer settings.
35
- * @param {number} layerIndex - Specifies the layer index.
36
- * @param {BingMap} bing - Specifies the bing map.
37
- * @returns {void}
38
- * @private
39
- */
40
- renderTileLayer(panel: LayerPanel, layer: LayerSettings, layerIndex: number, bing?: BingMap): void;
41
- protected processLayers(layer: LayerSettings, layerIndex: number): void;
42
- private bingMapCalculation;
43
- private bubbleCalculation;
44
- calculatePathCollection(layerIndex: number, renderData: any[]): void;
45
- /**
46
- * layer features as bubble, marker, datalabel, navigation line.
47
- *
48
- * @param {Element} groupElement - Specifies the element to append the group.
49
- * @param {Element} pathEle - Specifies the svg element.
50
- * @param {string} drawingType - Specifies the data type.
51
- * @param {any} currentShapeData - Specifies the layer of shapedata.
52
- * @returns {void}
53
- */
54
- private pathAttributeCalculate;
55
- /**
56
- * layer features as bubble, marker, datalabel, navigation line.
57
- *
58
- * @param {number} layerIndex - Specifies the layer index
59
- * @param {string[]} colors - Specifies the colors
60
- * @param {any[]} renderData - Specifies the render data
61
- * @param {HTMLElement} labelTemplateEle - Specifies the label template element
62
- * @returns {void}
63
- */
64
- private layerFeatures;
65
- /**
66
- * render datalabel.
67
- *
68
- * @param {LayerSettings} layer - Specifies the layer
69
- * @param {number} layerIndex - Specifies the layer index
70
- * @param {any[]} shape - Specifies the shape
71
- * @param {Element} group - Specifies the group
72
- * @param {number} shapeIndex - Specifies the shape index
73
- * @param {HTMLElement} labelTemplateEle - Specifies the label template element
74
- * @param {any[]} intersect - Specifies the intersect
75
- * @returns {void}
76
- */
77
- private renderLabel;
78
- /**
79
- * To render path for multipolygon.
80
- *
81
- * @param {any[]} currentShapeData Specifies the current shape data
82
- * @returns {string} Returns the path
83
- */
84
- private generateMultiPolygonPath;
85
- /**
86
- * To render bubble.
87
- *
88
- * @param {LayerSettings} layer - Specifies the layer
89
- * @param {object} bubbleData - Specifies the bubble data
90
- * @param {string} color - Specifies the color
91
- * @param {number} range - Specifies the range
92
- * @param {number} range.min - Specifies the minimum range
93
- * @param {number} range.max - Specifies the maximum range
94
- * @param {number} bubbleIndex - Specifies the bubble index
95
- * @param {number} dataIndex - Specifies the data index
96
- * @param {number} group - Specifies the group
97
- * @param {number} layerIndex - Specifies the layer index
98
- * @param {BubbleSettingsModel} bubbleSettings - Specifies the bubble settings
99
- * @returns {void}
100
- */
101
- private renderBubble;
102
- /**
103
- * To get the shape color from color mapping module.
104
- *
105
- * @param {LayerSettingsModel} layer - Specifies the layer
106
- * @param {any} shape - Specifies the shape
107
- * @param {string} color - Specifies the color
108
- * @returns {any} - Returns the object
109
- */
110
- private getShapeColorMapping;
111
- generatePoints(type: string, coordinates: any[], data: object, properties: object): void;
112
- calculateBox(point: Point, extraSpace: number): void;
113
- calculateFactor(layer: LayerSettings): number;
114
- translateLayerElements(layerElement: Element): void;
115
- calculateRectBounds(layerData: any[]): void;
116
- calculatePolygonBox(coordinates: any[]): any;
117
- calculateRectBox(coordinates: any[], type?: string, isFirstItem?: boolean): void;
118
- generateTiles(zoomLevel: number, tileTranslatePoint: Point, zoomType?: string, bing?: BingMap, position?: Point, isPinch?: boolean): void;
119
- arrangeTiles(type: string, x: number, y: number, isPinch?: boolean): void;
120
- private tileProcess;
121
- /**
122
- * Animation for tile layers and hide the group element until the tile layer rendering.
123
- *
124
- * @param {string} zoomType - Specifies the zoom type
125
- * @param {number} translateX - Specifies the x translate point
126
- * @param {number} translateY - Specifies the y translate point
127
- * @returns {void}
128
- */
129
- private tileAnimation;
130
- /**
131
- * To find the tile translate point.
132
- *
133
- * @param {number} factorX - Specifies the x factor
134
- * @param {number} factorY - Specifies the x factor
135
- * @param {MapLocation} centerPosition - Specifies the map location
136
- * @returns {Point} - Returns point values
137
- */
138
- private panTileMap;
139
- /**
140
- * @returns {void}
141
- * @private
142
- */
143
- destroy(): void;
144
- }