@syncfusion/ej2-maps 19.4.56 → 19.4.57-105067
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +18 -3
- package/.github/PULL_REQUEST_TEMPLATE/Bug.md +72 -72
- package/.github/PULL_REQUEST_TEMPLATE/Feature.md +49 -49
- package/CHANGELOG.md +441 -439
- package/README.md +73 -73
- package/dist/ej2-maps.umd.min.js +1 -10
- package/dist/ej2-maps.umd.min.js.map +1 -1
- package/dist/es6/ej2-maps.es2015.js +1161 -638
- package/dist/es6/ej2-maps.es2015.js.map +1 -1
- package/dist/es6/ej2-maps.es5.js +1200 -678
- package/dist/es6/ej2-maps.es5.js.map +1 -1
- package/dist/global/ej2-maps.min.js +1 -10
- package/dist/global/ej2-maps.min.js.map +1 -1
- package/dist/global/index.d.ts +0 -9
- package/dist/ts/maps/layers/bing-map.ts +50 -0
- package/dist/ts/maps/layers/bubble.ts +290 -0
- package/dist/ts/maps/layers/color-mapping.ts +226 -0
- package/dist/ts/maps/layers/data-label.ts +418 -0
- package/dist/ts/maps/layers/layer-panel.ts +1480 -0
- package/dist/ts/maps/layers/legend.ts +2236 -0
- package/dist/ts/maps/layers/marker.ts +453 -0
- package/dist/ts/maps/layers/navigation-selected-line.ts +167 -0
- package/dist/ts/maps/maps.ts +2886 -0
- package/dist/ts/maps/model/base.ts +1843 -0
- package/dist/ts/maps/model/constants.ts +200 -0
- package/dist/ts/maps/model/export-image.ts +178 -0
- package/dist/ts/maps/model/export-pdf.ts +170 -0
- package/dist/ts/maps/model/interface.ts +823 -0
- package/dist/ts/maps/model/print.ts +104 -0
- package/dist/ts/maps/model/theme.ts +554 -0
- package/dist/ts/maps/user-interaction/annotation.ts +127 -0
- package/dist/ts/maps/user-interaction/highlight.ts +233 -0
- package/dist/ts/maps/user-interaction/selection.ts +321 -0
- package/dist/ts/maps/user-interaction/tooltip.ts +387 -0
- package/dist/ts/maps/user-interaction/zoom.ts +1767 -0
- package/dist/ts/maps/utils/enum.ts +368 -0
- package/dist/ts/maps/utils/helper.ts +3421 -0
- package/helper/e2e/index.js +3 -3
- package/helper/e2e/maps-helper.js +13 -13
- package/license +9 -9
- package/package.json +85 -85
- package/src/maps/layers/bing-map.d.ts +4 -0
- package/src/maps/layers/bing-map.js +16 -3
- package/src/maps/layers/bubble.d.ts +1 -2
- package/src/maps/layers/bubble.js +7 -12
- package/src/maps/layers/data-label.d.ts +1 -4
- package/src/maps/layers/data-label.js +32 -35
- package/src/maps/layers/layer-panel.d.ts +18 -1
- package/src/maps/layers/layer-panel.js +226 -72
- package/src/maps/layers/legend.d.ts +5 -2
- package/src/maps/layers/legend.js +170 -61
- package/src/maps/layers/marker.d.ts +2 -4
- package/src/maps/layers/marker.js +49 -48
- package/src/maps/layers/navigation-selected-line.d.ts +1 -2
- package/src/maps/layers/navigation-selected-line.js +7 -13
- package/src/maps/maps-model.d.ts +259 -251
- package/src/maps/maps.d.ts +24 -3
- package/src/maps/maps.js +152 -90
- package/src/maps/model/base-model.d.ts +1025 -1021
- package/src/maps/model/base.d.ts +5 -1
- package/src/maps/model/base.js +24 -24
- package/src/maps/model/constants.d.ts +6 -0
- package/src/maps/model/constants.js +6 -0
- package/src/maps/model/export-image.d.ts +2 -4
- package/src/maps/model/export-image.js +26 -32
- package/src/maps/model/export-pdf.d.ts +4 -6
- package/src/maps/model/export-pdf.js +27 -35
- package/src/maps/model/interface.d.ts +34 -26
- package/src/maps/model/print.d.ts +2 -5
- package/src/maps/model/print.js +33 -21
- package/src/maps/model/theme.js +7 -4
- package/src/maps/user-interaction/annotation.d.ts +1 -2
- package/src/maps/user-interaction/annotation.js +3 -4
- package/src/maps/user-interaction/highlight.d.ts +1 -2
- package/src/maps/user-interaction/highlight.js +11 -10
- package/src/maps/user-interaction/selection.d.ts +1 -2
- package/src/maps/user-interaction/selection.js +42 -19
- package/src/maps/user-interaction/tooltip.d.ts +3 -5
- package/src/maps/user-interaction/tooltip.js +27 -14
- package/src/maps/user-interaction/zoom.d.ts +3 -8
- package/src/maps/user-interaction/zoom.js +282 -162
- package/src/maps/utils/enum.d.ts +5 -1
- package/src/maps/utils/helper.d.ts +1 -1
- package/src/maps/utils/helper.js +62 -31
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { Maps, ITooltipRenderEventArgs, tooltipRender, MapsTooltipOption, ITooltipRenderCompleteEventArgs, FontModel } from '../index';
|
|
3
|
+
import { Tooltip } from '@syncfusion/ej2-svg-base';
|
|
4
|
+
import { createElement, Browser, isNullOrUndefined, extend, remove } from '@syncfusion/ej2-base';
|
|
5
|
+
import { TooltipSettingsModel, LayerSettings, MarkerSettingsModel, BubbleSettingsModel } from '../index';
|
|
6
|
+
import { MapLocation, getMousePosition, Internalize, checkPropertyPath, getValueFromObject,
|
|
7
|
+
formatValue, convertStringToValue } from '../utils/helper';
|
|
8
|
+
import { click } from '../model/constants';
|
|
9
|
+
/**
|
|
10
|
+
* Map Tooltip
|
|
11
|
+
*/
|
|
12
|
+
export class MapsTooltip {
|
|
13
|
+
private maps: Maps;
|
|
14
|
+
/**
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
public svgTooltip: Tooltip;
|
|
18
|
+
private isTouch: boolean;
|
|
19
|
+
private tooltipId: string;
|
|
20
|
+
private clearTimeout: number;
|
|
21
|
+
public tooltipTargetID: string;
|
|
22
|
+
constructor(maps: Maps) {
|
|
23
|
+
this.maps = maps;
|
|
24
|
+
this.tooltipId = this.maps.element.id + '_mapsTooltip';
|
|
25
|
+
this.addEventListener();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public renderTooltip(e: PointerEvent): void {
|
|
29
|
+
let pageX: number; let pageY: number;
|
|
30
|
+
let target: Element; let touchArg: TouchEvent;
|
|
31
|
+
let tooltipArgs: ITooltipRenderEventArgs; let tooltipTemplateElement: HTMLElement;
|
|
32
|
+
if (e.type.indexOf('touch') !== - 1) {
|
|
33
|
+
this.isTouch = true;
|
|
34
|
+
touchArg = <TouchEvent & PointerEvent>e;
|
|
35
|
+
pageX = touchArg.changedTouches[0].pageX;
|
|
36
|
+
pageY = touchArg.changedTouches[0].pageY;
|
|
37
|
+
target = <Element>touchArg.target;
|
|
38
|
+
} else {
|
|
39
|
+
this.isTouch = e.pointerType === 'touch';
|
|
40
|
+
pageX = e.pageX;
|
|
41
|
+
pageY = e.pageY;
|
|
42
|
+
target = <Element>e.target;
|
|
43
|
+
}
|
|
44
|
+
let option: TooltipSettingsModel;
|
|
45
|
+
let currentData: string = '';
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
const targetId: string = target.id; const item: any = {};
|
|
48
|
+
let tooltipEle: HTMLElement;
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
50
|
+
let templateData: any = [];
|
|
51
|
+
let keyString: string;
|
|
52
|
+
let index: number = targetId.indexOf('_LayerIndex_') > -1 && parseFloat(targetId.split('_LayerIndex_')[1].split('_')[0]);
|
|
53
|
+
const layer: LayerSettings = <LayerSettings>this.maps.layersCollection[index];
|
|
54
|
+
const tooltipContent: string[] = []; let markerFill: string;
|
|
55
|
+
const location: MapLocation = getMousePosition(pageX, pageY, this.maps.svgObject);
|
|
56
|
+
this.tooltipTargetID = targetId;
|
|
57
|
+
const istooltipRender: boolean = (targetId.indexOf('_shapeIndex_') > -1)
|
|
58
|
+
|| (targetId.indexOf('_MarkerIndex_') > -1) || (targetId.indexOf('_BubbleIndex_') > -1);
|
|
59
|
+
if (istooltipRender) {
|
|
60
|
+
if (targetId.indexOf('_shapeIndex_') > -1) {
|
|
61
|
+
option = layer.tooltipSettings;
|
|
62
|
+
const shape: number = parseInt(targetId.split('_shapeIndex_')[1].split('_')[0], 10);
|
|
63
|
+
if (isNullOrUndefined(layer.layerData) || isNullOrUndefined(layer.layerData[shape])) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
const value: any = layer.layerData[shape]['property']; let isShape: boolean = false;
|
|
68
|
+
const properties: string[] = (Object.prototype.toString.call(layer.shapePropertyPath) === '[object Array]' ?
|
|
69
|
+
layer.shapePropertyPath : [layer.shapePropertyPath]) as string[];
|
|
70
|
+
if (!isNullOrUndefined(properties)) {
|
|
71
|
+
for (let k: number = 0; k < properties.length; k++) {
|
|
72
|
+
for (let i: number = 0; i < layer['dataSource']['length']; i++) {
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
const data: any[] = layer.dataSource[i];
|
|
75
|
+
const dataPath: string = (layer.shapeDataPath.indexOf('.') > -1 ) ?
|
|
76
|
+
(getValueFromObject(data, layer.shapeDataPath)) : data[layer.shapeDataPath];
|
|
77
|
+
const dataPathValue: string = !isNullOrUndefined(dataPath) && isNaN(data[layer.shapeDataPath])
|
|
78
|
+
? dataPath.toLowerCase() : dataPath;
|
|
79
|
+
const propertyValue: string = !isNullOrUndefined(value[properties[k]])
|
|
80
|
+
&& isNaN(value[properties[k]]) ? value[properties[k]].toLowerCase() :
|
|
81
|
+
value[properties[k]];
|
|
82
|
+
if (dataPathValue === propertyValue) {
|
|
83
|
+
isShape = true; index = i;
|
|
84
|
+
k = properties.length;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
index = isShape ? index : null;
|
|
90
|
+
if (!isNullOrUndefined(layer.dataSource[index])) {
|
|
91
|
+
templateData = JSON.parse(JSON.stringify(layer.dataSource[index]));
|
|
92
|
+
for (keyString in value) {
|
|
93
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
94
|
+
if (!templateData.hasOwnProperty(keyString)) {
|
|
95
|
+
templateData[keyString] = value[keyString];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (option.visible && ((!isNullOrUndefined(index) && !isNaN(index)) || (!isNullOrUndefined(value)))) {
|
|
101
|
+
if (layer.tooltipSettings.format) {
|
|
102
|
+
currentData = this.formatter(layer.tooltipSettings.format, templateData);
|
|
103
|
+
} else {
|
|
104
|
+
const shapePath: string = checkPropertyPath(layer.shapeDataPath, layer.shapePropertyPath, value);
|
|
105
|
+
currentData = (!isNullOrUndefined(layer.dataSource) && !isNullOrUndefined(index)) ?
|
|
106
|
+
formatValue(((option.valuePath.indexOf('.') > -1) ?
|
|
107
|
+
(getValueFromObject(layer.dataSource[index], option.valuePath)) :
|
|
108
|
+
layer.dataSource[index][option.valuePath]),
|
|
109
|
+
this.maps) : value[shapePath];
|
|
110
|
+
if (isNullOrUndefined(currentData)) {
|
|
111
|
+
currentData = (option.valuePath.indexOf('.') > -1) ?
|
|
112
|
+
(getValueFromObject(value, option.valuePath)) : value[option.valuePath];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//location.y = this.template(option, location);
|
|
117
|
+
|
|
118
|
+
} else if (targetId.indexOf('_MarkerIndex_') > -1) {
|
|
119
|
+
const markerIdex: number = parseInt(targetId.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
120
|
+
const dataIndex: number = parseInt(targetId.split('_MarkerIndex_')[1].split('_')[2], 10);
|
|
121
|
+
const marker: MarkerSettingsModel = layer.markerSettings[markerIdex];
|
|
122
|
+
option = marker.tooltipSettings;
|
|
123
|
+
templateData = marker.dataSource[dataIndex];
|
|
124
|
+
if (option.visible && !isNaN(markerIdex)) {
|
|
125
|
+
if (marker.tooltipSettings.format) {
|
|
126
|
+
currentData = this.formatter(marker.tooltipSettings.format, marker.dataSource[dataIndex]);
|
|
127
|
+
} else {
|
|
128
|
+
if (marker.template && !marker.tooltipSettings.valuePath) {
|
|
129
|
+
currentData = marker.template.split('>')[1].split('<')[0];
|
|
130
|
+
} else {
|
|
131
|
+
currentData =
|
|
132
|
+
formatValue(((marker.tooltipSettings.valuePath. indexOf('.') > -1) ?
|
|
133
|
+
(getValueFromObject(marker.dataSource[dataIndex], marker.tooltipSettings.valuePath)) :
|
|
134
|
+
marker.dataSource[dataIndex][marker.tooltipSettings.valuePath]),
|
|
135
|
+
this.maps
|
|
136
|
+
) as string;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
//location.y = this.template(option, location);
|
|
141
|
+
} else if (targetId.indexOf('_BubbleIndex_') > -1) {
|
|
142
|
+
const bubbleIndex: number = parseInt(targetId.split('_BubbleIndex_')[1].split('_')[0], 10);
|
|
143
|
+
const dataIndex: number = parseInt(targetId.split('_BubbleIndex_')[1].split('_')[2], 10);
|
|
144
|
+
const bubble: BubbleSettingsModel = layer.bubbleSettings[bubbleIndex];
|
|
145
|
+
option = bubble.tooltipSettings;
|
|
146
|
+
templateData = bubble.dataSource[dataIndex];
|
|
147
|
+
if (option.visible && !isNaN(dataIndex)) {
|
|
148
|
+
if (bubble.tooltipSettings.format) {
|
|
149
|
+
currentData = this.formatter(bubble.tooltipSettings.format, bubble.dataSource[dataIndex]);
|
|
150
|
+
} else {
|
|
151
|
+
currentData =
|
|
152
|
+
formatValue(((bubble.tooltipSettings.valuePath.indexOf('.') > -1) ?
|
|
153
|
+
(getValueFromObject(bubble.dataSource[dataIndex], bubble.tooltipSettings.valuePath)) :
|
|
154
|
+
bubble.dataSource[dataIndex][bubble.tooltipSettings.valuePath]),
|
|
155
|
+
this.maps
|
|
156
|
+
) as string;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//location.y = this.template(option, location);
|
|
160
|
+
}
|
|
161
|
+
if (document.getElementById(this.tooltipId)) {
|
|
162
|
+
tooltipEle = document.getElementById(this.tooltipId);
|
|
163
|
+
} else {
|
|
164
|
+
tooltipEle = createElement('div', {
|
|
165
|
+
id: this.maps.element.id + '_mapsTooltip',
|
|
166
|
+
className: 'EJ2-maps-Tooltip',
|
|
167
|
+
styles: 'position: absolute;pointer-events:none;'
|
|
168
|
+
});
|
|
169
|
+
document.getElementById(this.maps.element.id + '_Secondary_Element').appendChild(tooltipEle);
|
|
170
|
+
}
|
|
171
|
+
if (option.template !== null && Object.keys(typeof option.template === 'object' ? option.template : {}).length === 1) {
|
|
172
|
+
option.template = option.template[Object.keys(option.template)[0]];
|
|
173
|
+
}
|
|
174
|
+
templateData = this.setTooltipContent(option, templateData);
|
|
175
|
+
const tooltipTextStyle: FontModel = {
|
|
176
|
+
color: option.textStyle.color, fontFamily: option.textStyle.fontFamily, fontStyle: option.textStyle.fontStyle,
|
|
177
|
+
fontWeight: option.textStyle.fontWeight, opacity: option.textStyle.opacity, size: option.textStyle.size
|
|
178
|
+
};
|
|
179
|
+
const tooltipOption : MapsTooltipOption = {
|
|
180
|
+
location: location, text: tooltipContent, data: templateData,
|
|
181
|
+
textStyle: tooltipTextStyle,
|
|
182
|
+
template: option.template
|
|
183
|
+
};
|
|
184
|
+
tooltipArgs = {
|
|
185
|
+
cancel: false, name: tooltipRender,
|
|
186
|
+
options: tooltipOption,
|
|
187
|
+
fill: option.fill,
|
|
188
|
+
maps: this.maps,
|
|
189
|
+
element: target, eventArgs: e, content: !isNullOrUndefined(currentData) ? currentData.toString() : ''
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
this.maps.trigger(tooltipRender, tooltipArgs, (args: ITooltipRenderEventArgs) => {
|
|
193
|
+
if (!tooltipArgs.cancel && option.visible && !isNullOrUndefined(currentData) &&
|
|
194
|
+
(targetId.indexOf('_cluster_') === -1 && targetId.indexOf('_dataLabel_') === -1)) {
|
|
195
|
+
this.maps['isProtectedOnChange'] = true;
|
|
196
|
+
tooltipArgs.options['textStyle']['color'] = tooltipArgs.options['textStyle']['color']
|
|
197
|
+
|| this.maps.themeStyle.tooltipFontColor;
|
|
198
|
+
tooltipArgs.options['textStyle']['fontFamily'] = tooltipArgs.options['textStyle']['fontFamily']
|
|
199
|
+
|| this.maps.themeStyle.fontFamily;
|
|
200
|
+
tooltipArgs.options['textStyle']['opacity'] = tooltipArgs.options['textStyle']['opacity']
|
|
201
|
+
|| this.maps.themeStyle.tooltipTextOpacity;
|
|
202
|
+
if (tooltipArgs.cancel) {
|
|
203
|
+
this.svgTooltip = new Tooltip({
|
|
204
|
+
enable: true,
|
|
205
|
+
header: '',
|
|
206
|
+
data: option['data'],
|
|
207
|
+
template: option['template'],
|
|
208
|
+
content: tooltipArgs.content.toString() != currentData.toString() ? [tooltipArgs.content.toString()] : [currentData.toString()],
|
|
209
|
+
shapes: [],
|
|
210
|
+
location: option['location'],
|
|
211
|
+
palette: [markerFill],
|
|
212
|
+
areaBounds: this.maps.mapAreaRect,
|
|
213
|
+
textStyle: option['textStyle'],
|
|
214
|
+
availableSize: this.maps.availableSize,
|
|
215
|
+
fill: option.fill || this.maps.themeStyle.tooltipFillColor
|
|
216
|
+
});
|
|
217
|
+
} else {
|
|
218
|
+
this.svgTooltip = new Tooltip({
|
|
219
|
+
enable: true,
|
|
220
|
+
header: '',
|
|
221
|
+
data: tooltipArgs.options['data'],
|
|
222
|
+
template: tooltipArgs.options['template'],
|
|
223
|
+
content: tooltipArgs.content.toString() != currentData.toString() ? [tooltipArgs.content.toString()] : [currentData.toString()],
|
|
224
|
+
shapes: [],
|
|
225
|
+
location: tooltipArgs.options['location'],
|
|
226
|
+
palette: [markerFill],
|
|
227
|
+
areaBounds: this.maps.mapAreaRect,
|
|
228
|
+
textStyle: tooltipArgs.options['textStyle'],
|
|
229
|
+
availableSize: this.maps.availableSize,
|
|
230
|
+
fill: tooltipArgs.fill || this.maps.themeStyle.tooltipFillColor
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
234
|
+
if ((this.maps as any).isVue || (this.maps as any).isVue3) {
|
|
235
|
+
this.svgTooltip.controlInstance = this.maps;
|
|
236
|
+
}
|
|
237
|
+
this.svgTooltip.opacity = this.maps.themeStyle.tooltipFillOpacity || this.svgTooltip.opacity;
|
|
238
|
+
this.svgTooltip.appendTo(tooltipEle);
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
+
(this.maps as any).renderReactTemplates();
|
|
241
|
+
tooltipTemplateElement = document.getElementById(this.maps.element.id + '_mapsTooltip');
|
|
242
|
+
if (tooltipTemplateElement !== null && tooltipTemplateElement.innerHTML.indexOf('href') !== -1
|
|
243
|
+
&& tooltipTemplateElement.innerHTML.indexOf('</a>') !== -1) {
|
|
244
|
+
let templateStyle: string = tooltipTemplateElement.getAttribute('style');
|
|
245
|
+
templateStyle = templateStyle.replace('pointer-events: none;', 'position-events:all;');
|
|
246
|
+
tooltipTemplateElement.setAttribute('style', templateStyle);
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
this.clearTooltip();
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (this.svgTooltip) {
|
|
254
|
+
this.maps.trigger('tooltipRenderComplete', {
|
|
255
|
+
cancel: false, name: 'tooltipRenderComplete', maps: this.maps, options: tooltipOption,
|
|
256
|
+
element: this.svgTooltip.element
|
|
257
|
+
} as ITooltipRenderCompleteEventArgs);
|
|
258
|
+
}
|
|
259
|
+
if (this.svgTooltip) {
|
|
260
|
+
this.maps.trigger('tooltipRenderComplete', {
|
|
261
|
+
cancel: false, name: 'tooltipRenderComplete', maps: this.maps, options: tooltipOption, element: this.svgTooltip.element
|
|
262
|
+
} as ITooltipRenderCompleteEventArgs);
|
|
263
|
+
} else {
|
|
264
|
+
this.clearTooltip();
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
tooltipTemplateElement = document.getElementById(this.maps.element.id + '_mapsTooltip');
|
|
268
|
+
if (tooltipTemplateElement !== null && tooltipTemplateElement.innerHTML.indexOf('href') !== -1
|
|
269
|
+
&& tooltipTemplateElement.innerHTML.indexOf('</a>') !== -1) {
|
|
270
|
+
this.maps.notify(click, this);
|
|
271
|
+
} else {
|
|
272
|
+
this.clearTooltip();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* To get content for the current toolitp
|
|
279
|
+
*
|
|
280
|
+
* @param {TooltipSettingsModel} options - Specifies the options for rendering tooltip
|
|
281
|
+
* @param {any} templateData - Specifies the template data
|
|
282
|
+
* @returns {any} - Returns the local data
|
|
283
|
+
*/
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
private setTooltipContent(options: TooltipSettingsModel, templateData: any): any {
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
287
|
+
let localData: any = extend({}, templateData, null, true);
|
|
288
|
+
if (this.maps.format && !isNaN(Number(localData[options.valuePath]))) {
|
|
289
|
+
localData[options.valuePath] = Internalize(this.maps, Number(localData[options.valuePath]));
|
|
290
|
+
} else {
|
|
291
|
+
localData = Object.keys(localData).length ? localData : undefined;
|
|
292
|
+
}
|
|
293
|
+
return localData;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/*private template(tooltip: TooltipSettingsModel, location: MapLocation): number {
|
|
297
|
+
location.y = (tooltip.template) ? location.y + 10 : location.y;
|
|
298
|
+
return location.y;
|
|
299
|
+
}*/
|
|
300
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
301
|
+
private formatter(format: string, data: any = {}): string {
|
|
302
|
+
const keys: string[] = Object.keys(data);
|
|
303
|
+
for (const key of keys) {
|
|
304
|
+
format = (typeof data[key] === 'object') ? convertStringToValue('', format, data, this.maps) :
|
|
305
|
+
format.split('${' + key + '}').join(formatValue(data[key], this.maps));
|
|
306
|
+
}
|
|
307
|
+
return format;
|
|
308
|
+
}
|
|
309
|
+
public mouseUpHandler(e: PointerEvent): void {
|
|
310
|
+
this.renderTooltip(e);
|
|
311
|
+
if (this.maps.tooltipDisplayMode === 'MouseMove') {
|
|
312
|
+
clearTimeout(this.clearTimeout);
|
|
313
|
+
this.clearTimeout = setTimeout(this.removeTooltip.bind(this), 2000);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
public removeTooltip(): boolean {
|
|
318
|
+
let isTooltipRemoved: boolean = false;
|
|
319
|
+
if (document.getElementsByClassName('EJ2-maps-Tooltip').length > 0) {
|
|
320
|
+
remove(document.getElementsByClassName('EJ2-maps-Tooltip')[0]);
|
|
321
|
+
isTooltipRemoved = true;
|
|
322
|
+
}
|
|
323
|
+
return isTooltipRemoved;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
private clearTooltip(): void {
|
|
327
|
+
const isTooltipRemoved: boolean = this.removeTooltip();
|
|
328
|
+
if (isTooltipRemoved) {
|
|
329
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
330
|
+
(this.maps as any).clearTemplate();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// eslint-disable-next-line valid-jsdoc
|
|
334
|
+
/**
|
|
335
|
+
* To bind events for tooltip module
|
|
336
|
+
*/
|
|
337
|
+
public addEventListener(): void {
|
|
338
|
+
if (this.maps.isDestroyed) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (this.maps.tooltipDisplayMode === 'DoubleClick') {
|
|
342
|
+
this.maps.on('dblclick', this.renderTooltip, this);
|
|
343
|
+
} else if (this.maps.tooltipDisplayMode === 'Click') {
|
|
344
|
+
this.maps.on(Browser.touchEndEvent, this.mouseUpHandler, this);
|
|
345
|
+
} else {
|
|
346
|
+
this.maps.on(Browser.touchMoveEvent, this.renderTooltip, this);
|
|
347
|
+
}
|
|
348
|
+
this.maps.element.addEventListener('contextmenu', this.removeTooltip);
|
|
349
|
+
this.maps.on(Browser.touchCancelEvent, this.removeTooltip, this);
|
|
350
|
+
}
|
|
351
|
+
public removeEventListener(): void {
|
|
352
|
+
if (this.maps.isDestroyed) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (this.maps.tooltipDisplayMode === 'DoubleClick') {
|
|
356
|
+
this.maps.off('dblclick', this.removeTooltip);
|
|
357
|
+
} else if (this.maps.tooltipDisplayMode === 'Click') {
|
|
358
|
+
this.maps.off(Browser.touchEndEvent, this.mouseUpHandler);
|
|
359
|
+
} else {
|
|
360
|
+
this.maps.off(Browser.touchMoveEvent, this.renderTooltip);
|
|
361
|
+
}
|
|
362
|
+
this.maps.off(Browser.touchCancelEvent, this.removeTooltip);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Get module name.
|
|
366
|
+
*
|
|
367
|
+
* @returns {string} Returns the module name
|
|
368
|
+
*/
|
|
369
|
+
protected getModuleName(): string {
|
|
370
|
+
return 'MapsTooltip';
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* To destroy the tooltip.
|
|
374
|
+
*
|
|
375
|
+
* @returns {void}
|
|
376
|
+
* @private
|
|
377
|
+
*/
|
|
378
|
+
public destroy(): void {
|
|
379
|
+
if (!isNullOrUndefined(this.svgTooltip)) {
|
|
380
|
+
this.svgTooltip.destroy();
|
|
381
|
+
}
|
|
382
|
+
this.svgTooltip = null;
|
|
383
|
+
this.removeEventListener();
|
|
384
|
+
//TODO: Calling the below code throws spec issue.
|
|
385
|
+
//this.maps = null;
|
|
386
|
+
}
|
|
387
|
+
}
|