@syncfusion/ej2-maps 31.2.2 → 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.
- package/README.md +11 -2
- package/dist/ej2-maps.min.js +2 -2
- package/dist/ej2-maps.umd.min.js +2 -2
- package/dist/ej2-maps.umd.min.js.map +1 -1
- package/dist/es6/ej2-maps.es2015.js +84 -53
- package/dist/es6/ej2-maps.es2015.js.map +1 -1
- package/dist/es6/ej2-maps.es5.js +87 -56
- package/dist/es6/ej2-maps.es5.js.map +1 -1
- package/dist/global/ej2-maps.min.js +2 -2
- package/dist/global/ej2-maps.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +18 -53
- package/src/maps/layers/layer-panel.js +86 -55
- package/dist/ts/index.d.ts +0 -4
- package/dist/ts/index.ts +0 -4
- package/dist/ts/maps/index.d.ts +0 -28
- package/dist/ts/maps/index.ts +0 -28
- package/dist/ts/maps/layers/bing-map.d.ts +0 -21
- package/dist/ts/maps/layers/bing-map.ts +0 -51
- package/dist/ts/maps/layers/bubble.d.ts +0 -77
- package/dist/ts/maps/layers/bubble.ts +0 -304
- package/dist/ts/maps/layers/color-mapping.d.ts +0 -36
- package/dist/ts/maps/layers/color-mapping.ts +0 -230
- package/dist/ts/maps/layers/data-label.d.ts +0 -45
- package/dist/ts/maps/layers/data-label.ts +0 -457
- package/dist/ts/maps/layers/layer-panel.d.ts +0 -144
- package/dist/ts/maps/layers/layer-panel.ts +0 -1455
- package/dist/ts/maps/layers/legend.d.ts +0 -173
- package/dist/ts/maps/layers/legend.ts +0 -2465
- package/dist/ts/maps/layers/marker.d.ts +0 -105
- package/dist/ts/maps/layers/marker.ts +0 -632
- package/dist/ts/maps/layers/navigation-selected-line.d.ts +0 -33
- package/dist/ts/maps/layers/navigation-selected-line.ts +0 -171
- package/dist/ts/maps/layers/polygon.d.ts +0 -30
- package/dist/ts/maps/layers/polygon.ts +0 -68
- package/dist/ts/maps/maps-model.d.ts +0 -409
- package/dist/ts/maps/maps.d.ts +0 -1247
- package/dist/ts/maps/maps.ts +0 -3416
- package/dist/ts/maps/model/base-model.d.ts +0 -2107
- package/dist/ts/maps/model/base.d.ts +0 -1840
- package/dist/ts/maps/model/base.ts +0 -2257
- package/dist/ts/maps/model/constants.d.ts +0 -225
- package/dist/ts/maps/model/constants.ts +0 -226
- package/dist/ts/maps/model/export-image.d.ts +0 -39
- package/dist/ts/maps/model/export-image.ts +0 -194
- package/dist/ts/maps/model/export-pdf.d.ts +0 -40
- package/dist/ts/maps/model/export-pdf.ts +0 -183
- package/dist/ts/maps/model/interface.d.ts +0 -892
- package/dist/ts/maps/model/interface.ts +0 -929
- package/dist/ts/maps/model/print.d.ts +0 -45
- package/dist/ts/maps/model/print.ts +0 -125
- package/dist/ts/maps/model/theme.d.ts +0 -98
- package/dist/ts/maps/model/theme.ts +0 -919
- package/dist/ts/maps/user-interaction/annotation.d.ts +0 -27
- package/dist/ts/maps/user-interaction/annotation.ts +0 -133
- package/dist/ts/maps/user-interaction/highlight.d.ts +0 -63
- package/dist/ts/maps/user-interaction/highlight.ts +0 -272
- package/dist/ts/maps/user-interaction/selection.d.ts +0 -85
- package/dist/ts/maps/user-interaction/selection.ts +0 -342
- package/dist/ts/maps/user-interaction/tooltip.d.ts +0 -78
- package/dist/ts/maps/user-interaction/tooltip.ts +0 -500
- package/dist/ts/maps/user-interaction/zoom.d.ts +0 -334
- package/dist/ts/maps/user-interaction/zoom.ts +0 -2523
- package/dist/ts/maps/utils/enum.d.ts +0 -328
- package/dist/ts/maps/utils/enum.ts +0 -343
- package/dist/ts/maps/utils/helper.d.ts +0 -1318
- package/dist/ts/maps/utils/helper.ts +0 -3811
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
import { Maps, ITooltipRenderEventArgs, tooltipRender, MapsTooltipOption, ITooltipRenderCompleteEventArgs, FontModel, PolygonTooltipSettingsModel, PolygonSettingModel, GeoPosition, BorderModel } from '../index';
|
|
2
|
-
import { Tooltip, TooltipTheme } from '@syncfusion/ej2-svg-base';
|
|
3
|
-
import { createElement, Browser, isNullOrUndefined, extend, remove } from '@syncfusion/ej2-base';
|
|
4
|
-
import { TooltipSettingsModel, LayerSettings, MarkerSettingsModel, BubbleSettingsModel } from '../index';
|
|
5
|
-
import { MapLocation, getMousePosition, Internalize, checkPropertyPath, getValueFromObject,
|
|
6
|
-
formatValue, convertStringToValue, removeElement} from '../utils/helper';
|
|
7
|
-
/**
|
|
8
|
-
* Map Tooltip
|
|
9
|
-
*/
|
|
10
|
-
export class MapsTooltip {
|
|
11
|
-
private maps: Maps;
|
|
12
|
-
/**
|
|
13
|
-
* @private
|
|
14
|
-
*/
|
|
15
|
-
public svgTooltip: Tooltip;
|
|
16
|
-
private isTouch: boolean;
|
|
17
|
-
private tooltipId: string;
|
|
18
|
-
private tooltipTimer: number;
|
|
19
|
-
/**
|
|
20
|
-
* @private
|
|
21
|
-
*/
|
|
22
|
-
public tooltipTargetID: string;
|
|
23
|
-
constructor(maps: Maps) {
|
|
24
|
-
this.maps = maps;
|
|
25
|
-
this.tooltipId = this.maps.element.id + '_mapsTooltip';
|
|
26
|
-
this.addEventListener();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @param {PointerEvent} e - Specifies the event.
|
|
31
|
-
* @returns {void}
|
|
32
|
-
* @private
|
|
33
|
-
*/
|
|
34
|
-
public renderTooltip(e: PointerEvent): void {
|
|
35
|
-
let pageX: number; let pageY: number;
|
|
36
|
-
let target: Element; let touchArg: TouchEvent;
|
|
37
|
-
let tooltipArgs: ITooltipRenderEventArgs;
|
|
38
|
-
if (e.type.indexOf('touch') !== - 1) {
|
|
39
|
-
this.isTouch = true;
|
|
40
|
-
touchArg = <TouchEvent & PointerEvent>e;
|
|
41
|
-
pageX = touchArg.changedTouches[0].pageX;
|
|
42
|
-
pageY = touchArg.changedTouches[0].pageY;
|
|
43
|
-
target = <Element>touchArg.target;
|
|
44
|
-
} else {
|
|
45
|
-
this.isTouch = e.pointerType === 'touch';
|
|
46
|
-
pageX = e.pageX;
|
|
47
|
-
pageY = e.pageY;
|
|
48
|
-
target = <Element>e.target;
|
|
49
|
-
}
|
|
50
|
-
if (target.id.indexOf(this.maps.element.id) === -1) {
|
|
51
|
-
const ancestor: Element = target.closest('.' + this.maps.element.id + '_marker_template_element');
|
|
52
|
-
if (!isNullOrUndefined(ancestor) && ancestor.id.indexOf('_MarkerIndex_') > -1) {
|
|
53
|
-
target = ancestor;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
let option: TooltipSettingsModel;
|
|
57
|
-
let polygonTooltipOption : PolygonTooltipSettingsModel;
|
|
58
|
-
let currentData: string = '';
|
|
59
|
-
const targetId: string = target.id;
|
|
60
|
-
let tooltipEle: HTMLElement;
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
-
let templateData: any = [];
|
|
63
|
-
let keyString: string;
|
|
64
|
-
let index: number = targetId.indexOf('_LayerIndex_') > -1 && parseFloat(targetId.split('_LayerIndex_')[1].split('_')[0]);
|
|
65
|
-
const layer: LayerSettings = <LayerSettings>this.maps.layersCollection[index as number];
|
|
66
|
-
const tooltipContent: string[] = []; let markerFill: string;
|
|
67
|
-
const location: MapLocation = getMousePosition(pageX, pageY, this.maps.svgObject);
|
|
68
|
-
this.tooltipTargetID = targetId;
|
|
69
|
-
let polygonTextStyle: FontModel;
|
|
70
|
-
let polygonFill : string;
|
|
71
|
-
let polygon : PolygonSettingModel;
|
|
72
|
-
let latitude: number = null;
|
|
73
|
-
let longitude: number = null;
|
|
74
|
-
const latLongValue: GeoPosition = this.maps.getClickLocation(targetId, e.pageX, e.pageY, (target as HTMLElement), e['layerX'], e['layerY'], 'tooltip');
|
|
75
|
-
if (!isNullOrUndefined(latLongValue)) {
|
|
76
|
-
latitude = latLongValue.latitude;
|
|
77
|
-
longitude = latLongValue.longitude;
|
|
78
|
-
}
|
|
79
|
-
const isPolygon: boolean = targetId.indexOf('_PolygonIndex_') > -1;
|
|
80
|
-
const istooltipRender: boolean = (targetId.indexOf('_shapeIndex_') > -1)
|
|
81
|
-
|| (targetId.indexOf('_MarkerIndex_') > -1) || (targetId.indexOf('_BubbleIndex_') > -1)
|
|
82
|
-
|| (targetId.indexOf('_PolygonIndex_') > -1);
|
|
83
|
-
if (istooltipRender && this.maps.markerDragArgument === null) {
|
|
84
|
-
if (targetId.indexOf('_PolygonIndex_') > -1) {
|
|
85
|
-
const polygonIndex: number = parseInt(targetId.split('_PolygonIndex_')[1].split('_')[0], 10);
|
|
86
|
-
polygonTooltipOption = layer.polygonSettings.tooltipSettings;
|
|
87
|
-
polygon = layer.polygonSettings.polygons[polygonIndex as number];
|
|
88
|
-
polygonTextStyle = polygonTooltipOption.textStyle;
|
|
89
|
-
polygonFill = polygonTooltipOption.fill;
|
|
90
|
-
tooltipContent.push(polygon.tooltipText);
|
|
91
|
-
} else if (targetId.indexOf('_shapeIndex_') > -1) {
|
|
92
|
-
option = layer.tooltipSettings;
|
|
93
|
-
const shape: number = parseInt(targetId.split('_shapeIndex_')[1].split('_')[0], 10);
|
|
94
|
-
if (isNullOrUndefined(layer.layerData) || isNullOrUndefined(layer.layerData[shape as number])) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
-
const value: any = layer.layerData[shape as number]['property']; let isShape: boolean = false;
|
|
99
|
-
const properties: string[] = (Object.prototype.toString.call(layer.shapePropertyPath) === '[object Array]' ?
|
|
100
|
-
layer.shapePropertyPath : [layer.shapePropertyPath]) as string[];
|
|
101
|
-
if (!isNullOrUndefined(properties)) {
|
|
102
|
-
for (let k: number = 0; k < properties.length; k++) {
|
|
103
|
-
if (!isNullOrUndefined(layer.dataSource) && !isNullOrUndefined(layer.shapeDataPath)) {
|
|
104
|
-
for (let i: number = 0; i < layer['dataSource']['length']; i++) {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
const data: any[] = layer.dataSource[i as number];
|
|
107
|
-
const dataPath: string = (layer.shapeDataPath.indexOf('.') > -1) ?
|
|
108
|
-
(getValueFromObject(data, layer.shapeDataPath)) : data[layer.shapeDataPath];
|
|
109
|
-
const dataPathValue: string = !isNullOrUndefined(dataPath) && isNaN(data[layer.shapeDataPath])
|
|
110
|
-
? dataPath.toLowerCase() : dataPath;
|
|
111
|
-
const propertyValue: string = !isNullOrUndefined(value[properties[k as number]])
|
|
112
|
-
&& isNaN(value[properties[k as number]]) ? value[properties[k as number]].toLowerCase() :
|
|
113
|
-
value[properties[k as number]];
|
|
114
|
-
if (dataPathValue === propertyValue) {
|
|
115
|
-
isShape = true; index = i;
|
|
116
|
-
k = properties.length;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
index = isShape ? index : null;
|
|
123
|
-
if (layer['dataSource'] && layer['dataSource']['length'] > 0) {
|
|
124
|
-
if (!isNullOrUndefined(layer.dataSource[index as number])) {
|
|
125
|
-
templateData = JSON.parse(JSON.stringify(layer.dataSource[index as number]));
|
|
126
|
-
for (keyString in value) {
|
|
127
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
128
|
-
if (!templateData.hasOwnProperty(keyString)) {
|
|
129
|
-
templateData[keyString as string] = value[keyString as string];
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
} else {
|
|
134
|
-
templateData = value;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
if (option.visible && ((!isNullOrUndefined(index) && !isNaN(index)) || (!isNullOrUndefined(value)))) {
|
|
138
|
-
if (layer.tooltipSettings.format) {
|
|
139
|
-
currentData = this.formatter(layer.tooltipSettings.format, templateData);
|
|
140
|
-
} else {
|
|
141
|
-
const shapePath: string = checkPropertyPath(layer.shapeDataPath, layer.shapePropertyPath, value);
|
|
142
|
-
currentData = (!isNullOrUndefined(layer.dataSource) && !isNullOrUndefined(index)) ?
|
|
143
|
-
formatValue(((option.valuePath.indexOf('.') > -1) ?
|
|
144
|
-
(getValueFromObject(layer.dataSource[index as number], option.valuePath)) :
|
|
145
|
-
layer.dataSource[index as number][option.valuePath]),
|
|
146
|
-
this.maps) : value[shapePath as string];
|
|
147
|
-
if (isNullOrUndefined(currentData) && !isNullOrUndefined(option.valuePath)) {
|
|
148
|
-
currentData = (option.valuePath.indexOf('.') > -1) ?
|
|
149
|
-
(getValueFromObject(value, option.valuePath)) : value[option.valuePath];
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
//location.y = this.template(option, location);
|
|
154
|
-
|
|
155
|
-
} else if (targetId.indexOf('_MarkerIndex_') > -1) {
|
|
156
|
-
const markerIdex: number = parseInt(targetId.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
157
|
-
const dataIndex: number = parseInt(targetId.split('_MarkerIndex_')[1].split('_')[2], 10);
|
|
158
|
-
const marker: MarkerSettingsModel = layer.markerSettings[markerIdex as number];
|
|
159
|
-
option = marker.tooltipSettings;
|
|
160
|
-
templateData = marker.dataSource[dataIndex as number];
|
|
161
|
-
if (option.visible && !isNaN(markerIdex)) {
|
|
162
|
-
if (marker.tooltipSettings.format) {
|
|
163
|
-
currentData = this.formatter(marker.tooltipSettings.format, marker.dataSource[dataIndex as number]);
|
|
164
|
-
} else {
|
|
165
|
-
if (typeof marker.template !== 'function' && marker.template && !marker.tooltipSettings.valuePath) {
|
|
166
|
-
currentData = marker.template.split('>')[1].split('<')[0];
|
|
167
|
-
} else {
|
|
168
|
-
if (!isNullOrUndefined(marker.tooltipSettings.valuePath)) {
|
|
169
|
-
currentData =
|
|
170
|
-
formatValue(((marker.tooltipSettings.valuePath. indexOf('.') > -1) ?
|
|
171
|
-
(getValueFromObject(marker.dataSource[dataIndex as number], marker.tooltipSettings.valuePath)) :
|
|
172
|
-
marker.dataSource[dataIndex as number][marker.tooltipSettings.valuePath]),
|
|
173
|
-
this.maps
|
|
174
|
-
) as string;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
//location.y = this.template(option, location);
|
|
180
|
-
} else if (targetId.indexOf('_BubbleIndex_') > -1) {
|
|
181
|
-
const bubbleIndex: number = parseInt(targetId.split('_BubbleIndex_')[1].split('_')[0], 10);
|
|
182
|
-
const dataIndex: number = parseInt(targetId.split('_BubbleIndex_')[1].split('_')[2], 10);
|
|
183
|
-
const bubble: BubbleSettingsModel = layer.bubbleSettings[bubbleIndex as number];
|
|
184
|
-
option = bubble.tooltipSettings;
|
|
185
|
-
templateData = bubble.dataSource[dataIndex as number];
|
|
186
|
-
if (option.visible && !isNaN(dataIndex)) {
|
|
187
|
-
if (bubble.tooltipSettings.format) {
|
|
188
|
-
currentData = this.formatter(bubble.tooltipSettings.format, bubble.dataSource[dataIndex as number]);
|
|
189
|
-
} else {
|
|
190
|
-
if (!isNullOrUndefined(bubble.tooltipSettings.valuePath)) {
|
|
191
|
-
currentData =
|
|
192
|
-
formatValue(((bubble.tooltipSettings.valuePath.indexOf('.') > -1) ?
|
|
193
|
-
(getValueFromObject(bubble.dataSource[dataIndex as number], bubble.tooltipSettings.valuePath)) :
|
|
194
|
-
bubble.dataSource[dataIndex as number][bubble.tooltipSettings.valuePath]),
|
|
195
|
-
this.maps
|
|
196
|
-
) as string;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
//location.y = this.template(option, location);
|
|
201
|
-
}
|
|
202
|
-
if (isPolygon ? polygonTooltipOption.visible : option.visible) {
|
|
203
|
-
if (document.getElementById(this.tooltipId)) {
|
|
204
|
-
tooltipEle = document.getElementById(this.tooltipId);
|
|
205
|
-
} else {
|
|
206
|
-
tooltipEle = createElement('div', {
|
|
207
|
-
id: this.maps.element.id + '_mapsTooltip',
|
|
208
|
-
className: 'EJ2-maps-Tooltip'
|
|
209
|
-
});
|
|
210
|
-
if (isNullOrUndefined(isPolygon ? polygon.tooltipTemplate : option.template) || (isPolygon ? polygon.tooltipTemplate === '' : option.template === '') || this.maps.tooltipDisplayMode === 'MouseMove') {
|
|
211
|
-
tooltipEle.style.cssText = 'position: absolute;pointer-events:none;';
|
|
212
|
-
} else {
|
|
213
|
-
tooltipEle.style.position = 'absolute';
|
|
214
|
-
}
|
|
215
|
-
document.getElementById(this.maps.element.id + '_Secondary_Element').appendChild(tooltipEle);
|
|
216
|
-
}
|
|
217
|
-
// eslint-disable-next-line no-constant-condition
|
|
218
|
-
if (typeof (isPolygon ? polygon.tooltipTemplate !== 'function' : option.template !== 'function') && (isPolygon ? polygon.tooltipTemplate !== null : option.template !== null) && Object.keys(typeof (isPolygon ? polygon.tooltipTemplate === 'object' : option.template === 'object') ? (isPolygon ? polygon.tooltipTemplate : option.template) : {}).length === 1) {
|
|
219
|
-
if (isPolygon) {
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
221
|
-
polygon.tooltipTemplate = polygon.tooltipTemplate[Object.keys(polygon.tooltipTemplate as any)[0]];
|
|
222
|
-
} else {
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
224
|
-
option.template = option.template[Object.keys(option.template as any)[0]];
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
templateData = this.setTooltipContent(option, templateData);
|
|
228
|
-
const tooltipTextStyle: FontModel = {
|
|
229
|
-
// eslint-disable-next-line max-len
|
|
230
|
-
color: isPolygon ? polygonTextStyle.color : option.textStyle.color, fontFamily: isPolygon ? polygonTextStyle.fontFamily : option.textStyle.fontFamily, fontStyle: isPolygon ? polygonTextStyle.fontStyle : option.textStyle.fontStyle,
|
|
231
|
-
// eslint-disable-next-line max-len
|
|
232
|
-
fontWeight: isPolygon ? polygonTextStyle.fontWeight : option.textStyle.fontWeight, opacity: isPolygon ? polygonTextStyle.opacity : option.textStyle.opacity, size: isPolygon ? polygonTextStyle.size : option.textStyle.size
|
|
233
|
-
};
|
|
234
|
-
const tooltipOption : MapsTooltipOption = {
|
|
235
|
-
location: location, text: tooltipContent, data: templateData,
|
|
236
|
-
textStyle: tooltipTextStyle,
|
|
237
|
-
template: isPolygon ? polygon.tooltipTemplate : option.template
|
|
238
|
-
};
|
|
239
|
-
tooltipArgs = {
|
|
240
|
-
cancel: false, name: tooltipRender,
|
|
241
|
-
options: tooltipOption,
|
|
242
|
-
fill: isPolygon ? polygonFill : option.fill,
|
|
243
|
-
maps: this.maps, latitude: latitude, longitude: longitude,
|
|
244
|
-
element: target, eventArgs: e, content: isPolygon ? (!isNullOrUndefined(polygon.tooltipText) ? polygon.tooltipText : '') :
|
|
245
|
-
!isNullOrUndefined(currentData) ? currentData.toString() : ''
|
|
246
|
-
};
|
|
247
|
-
if (tooltipArgs.content !== '' || tooltipArgs.options['template'] !== '') {
|
|
248
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
249
|
-
this.maps.trigger(tooltipRender, tooltipArgs, (args: ITooltipRenderEventArgs) => {
|
|
250
|
-
if (!tooltipArgs.cancel && !isNullOrUndefined(currentData) &&
|
|
251
|
-
(targetId.indexOf('_cluster_') === -1 && targetId.indexOf('_dataLabel_') === -1)) {
|
|
252
|
-
this.maps['isProtectedOnChange'] = true;
|
|
253
|
-
tooltipArgs.options['textStyle']['size'] = tooltipArgs.options['textStyle']['size']
|
|
254
|
-
|| this.maps.themeStyle.fontSize;
|
|
255
|
-
tooltipArgs.options['textStyle']['color'] = tooltipArgs.options['textStyle']['color']
|
|
256
|
-
|| this.maps.themeStyle.tooltipFontColor;
|
|
257
|
-
tooltipArgs.options['textStyle']['fontFamily'] = tooltipArgs.options['textStyle']['fontFamily']
|
|
258
|
-
|| this.maps.themeStyle.fontFamily;
|
|
259
|
-
tooltipArgs.options['textStyle']['fontWeight'] = tooltipArgs.options['textStyle']['fontWeight']
|
|
260
|
-
|| this.maps.themeStyle.fontWeight;
|
|
261
|
-
tooltipArgs.options['textStyle']['opacity'] = tooltipArgs.options['textStyle']['opacity']
|
|
262
|
-
|| this.maps.themeStyle.tooltipTextOpacity;
|
|
263
|
-
const borderObject: BorderModel = isPolygon ? {
|
|
264
|
-
color: polygonTooltipOption.border.color ||
|
|
265
|
-
this.maps.themeStyle.tooltipBorderColor, width: polygonTooltipOption.border.width,
|
|
266
|
-
opacity: polygonTooltipOption.border.opacity
|
|
267
|
-
} : {
|
|
268
|
-
color: option.border.color ||
|
|
269
|
-
this.maps.themeStyle.tooltipBorderColor, width: option.border.width, opacity: option.border.opacity
|
|
270
|
-
};
|
|
271
|
-
if (tooltipArgs.cancel) {
|
|
272
|
-
this.svgTooltip = new Tooltip({
|
|
273
|
-
theme: this.maps.theme as TooltipTheme,
|
|
274
|
-
enable: true,
|
|
275
|
-
header: '',
|
|
276
|
-
data: option['data'],
|
|
277
|
-
template: option['template'],
|
|
278
|
-
content: tooltipArgs.content.toString() !== currentData.toString() ? [tooltipArgs.content.toString()] :
|
|
279
|
-
[currentData.toString()],
|
|
280
|
-
shapes: [],
|
|
281
|
-
location: option['location'],
|
|
282
|
-
palette: [markerFill],
|
|
283
|
-
areaBounds: this.maps.mapAreaRect,
|
|
284
|
-
textStyle: option['textStyle'],
|
|
285
|
-
availableSize: this.maps.availableSize,
|
|
286
|
-
fill: option.fill || this.maps.themeStyle.tooltipFillColor,
|
|
287
|
-
enableShadow: true,
|
|
288
|
-
border: borderObject
|
|
289
|
-
});
|
|
290
|
-
} else {
|
|
291
|
-
this.svgTooltip = new Tooltip({
|
|
292
|
-
theme: this.maps.theme as TooltipTheme,
|
|
293
|
-
enable: true,
|
|
294
|
-
header: '',
|
|
295
|
-
data: tooltipArgs.options['data'],
|
|
296
|
-
template: tooltipArgs.options['template'],
|
|
297
|
-
content: tooltipArgs.content.toString() !== currentData.toString() ? [tooltipArgs.content.toString()] :
|
|
298
|
-
[currentData.toString()],
|
|
299
|
-
shapes: [],
|
|
300
|
-
location: tooltipArgs.options['location'],
|
|
301
|
-
palette: [markerFill],
|
|
302
|
-
areaBounds: this.maps.mapAreaRect,
|
|
303
|
-
textStyle: tooltipArgs.options['textStyle'],
|
|
304
|
-
availableSize: this.maps.availableSize,
|
|
305
|
-
fill: tooltipArgs.fill || this.maps.themeStyle.tooltipFillColor,
|
|
306
|
-
enableShadow: true,
|
|
307
|
-
border: borderObject
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
311
|
-
if ((this.maps as any).isVue || (this.maps as any).isVue3) {
|
|
312
|
-
this.svgTooltip.controlInstance = this.maps;
|
|
313
|
-
}
|
|
314
|
-
this.svgTooltip.opacity = this.maps.themeStyle.tooltipFillOpacity || this.svgTooltip.opacity;
|
|
315
|
-
this.svgTooltip.appendTo(tooltipEle);
|
|
316
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
317
|
-
(this.maps as any).renderReactTemplates();
|
|
318
|
-
if (this.maps.isDevice) {
|
|
319
|
-
let timer: number = targetId.indexOf('_MarkerIndex_') > -1 || targetId.indexOf('_BubbleIndex_') > -1
|
|
320
|
-
|| targetId.indexOf('_shapeIndex_') > -1 ? option.duration : polygonTooltipOption.duration;
|
|
321
|
-
timer = (!isNullOrUndefined(timer) && timer > 0) ? timer : (timer < 0) ? 2000 : null;
|
|
322
|
-
if (timer !== null) {
|
|
323
|
-
clearTimeout(this.tooltipTimer);
|
|
324
|
-
this.tooltipTimer = setTimeout(this.removeTooltip.bind(this), timer);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
} else {
|
|
328
|
-
this.clearTooltip(<HTMLElement>e.target);
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
} else {
|
|
332
|
-
this.clearTooltip(<HTMLElement>e.target);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (this.svgTooltip) {
|
|
336
|
-
this.maps.trigger('tooltipRenderComplete', {
|
|
337
|
-
cancel: false, name: 'tooltipRenderComplete', maps: this.maps, options: tooltipOption,
|
|
338
|
-
element: this.svgTooltip.element
|
|
339
|
-
} as ITooltipRenderCompleteEventArgs);
|
|
340
|
-
}
|
|
341
|
-
if (this.svgTooltip) {
|
|
342
|
-
this.maps.trigger('tooltipRenderComplete', {
|
|
343
|
-
cancel: false, name: 'tooltipRenderComplete', maps: this.maps, options: tooltipOption, element: this.svgTooltip.element
|
|
344
|
-
} as ITooltipRenderCompleteEventArgs);
|
|
345
|
-
} else {
|
|
346
|
-
this.clearTooltip(<HTMLElement>e.target);
|
|
347
|
-
}
|
|
348
|
-
} else {
|
|
349
|
-
this.clearTooltip(<HTMLElement>e.target);
|
|
350
|
-
}
|
|
351
|
-
} else {
|
|
352
|
-
const tooltipElement: Element = (e.target as HTMLElement).closest('#' + this.maps.element.id + '_mapsTooltipparent_template');
|
|
353
|
-
if (isNullOrUndefined(tooltipElement)) {
|
|
354
|
-
this.clearTooltip(<HTMLElement>e.target);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* To get content for the current toolitp.
|
|
361
|
-
*
|
|
362
|
-
* @param {TooltipSettingsModel} options - Specifies the options for rendering tooltip
|
|
363
|
-
* @param {any} templateData - Specifies the template data
|
|
364
|
-
* @returns {any} - Returns the local data
|
|
365
|
-
*/
|
|
366
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
367
|
-
private setTooltipContent(options: TooltipSettingsModel, templateData: any): any {
|
|
368
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
369
|
-
let localData: any = extend({}, templateData, null, true);
|
|
370
|
-
if (this.maps.format && !isNaN(Number(localData[options.valuePath]))) {
|
|
371
|
-
localData[options.valuePath] = Internalize(this.maps, Number(localData[options.valuePath]));
|
|
372
|
-
} else {
|
|
373
|
-
localData = Object.keys(localData).length ? localData : undefined;
|
|
374
|
-
}
|
|
375
|
-
return localData;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/*private template(tooltip: TooltipSettingsModel, location: MapLocation): number {
|
|
379
|
-
location.y = (tooltip.template) ? location.y + 10 : location.y;
|
|
380
|
-
return location.y;
|
|
381
|
-
}*/
|
|
382
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
383
|
-
private formatter(format: string, data: any = {}): string {
|
|
384
|
-
const keys: string[] = Object.keys(data);
|
|
385
|
-
for (const key of keys) {
|
|
386
|
-
format = (typeof data[key as string] === 'object') ? convertStringToValue('', format, data, this.maps) :
|
|
387
|
-
format.split('${' + key + '}').join(formatValue(data[key as string], this.maps));
|
|
388
|
-
}
|
|
389
|
-
return format;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Handles the mouse up.
|
|
393
|
-
*
|
|
394
|
-
* @param {PointerEvent} e - Specifies the event
|
|
395
|
-
* @returns {void}
|
|
396
|
-
* @private
|
|
397
|
-
*/
|
|
398
|
-
public mouseUpHandler(e: PointerEvent): void {
|
|
399
|
-
if (!isNullOrUndefined(this.maps)) {
|
|
400
|
-
this.renderTooltip(e);
|
|
401
|
-
if (this.maps.tooltipDisplayMode === 'MouseMove') {
|
|
402
|
-
clearTimeout(this.tooltipTimer);
|
|
403
|
-
this.tooltipTimer = setTimeout(this.removeTooltip.bind(this), 2000);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Removes the tooltip.
|
|
410
|
-
*
|
|
411
|
-
* @returns {boolean} - Returns the boolean whether tooltip is removed or not.
|
|
412
|
-
* @private
|
|
413
|
-
*/
|
|
414
|
-
public removeTooltip(): boolean {
|
|
415
|
-
let isTooltipRemoved: boolean = false;
|
|
416
|
-
if (document.getElementsByClassName('EJ2-maps-Tooltip').length > 0) {
|
|
417
|
-
remove(document.getElementsByClassName('EJ2-maps-Tooltip')[0]);
|
|
418
|
-
isTooltipRemoved = true;
|
|
419
|
-
}
|
|
420
|
-
return isTooltipRemoved;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
private clearTooltip(element: HTMLElement): void {
|
|
424
|
-
// eslint-disable-next-line @typescript-eslint/tslint/config
|
|
425
|
-
const tooltipElement = element.closest('#' + this.maps.element.id + '_mapsTooltipparent_template');
|
|
426
|
-
if (isNullOrUndefined(tooltipElement)) {
|
|
427
|
-
const isTooltipRemoved: boolean = this.removeTooltip();
|
|
428
|
-
if (isTooltipRemoved) {
|
|
429
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
430
|
-
(this.maps as any).clearTemplate();
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* To bind events for tooltip module.
|
|
437
|
-
*
|
|
438
|
-
* @returns {void}
|
|
439
|
-
* @private
|
|
440
|
-
*/
|
|
441
|
-
public addEventListener(): void {
|
|
442
|
-
if (this.maps.isDestroyed) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
if (this.maps.tooltipDisplayMode === 'DoubleClick') {
|
|
446
|
-
this.maps.on('dblclick', this.renderTooltip, this);
|
|
447
|
-
} else if (this.maps.tooltipDisplayMode === 'Click') {
|
|
448
|
-
this.maps.on(Browser.touchEndEvent, this.mouseUpHandler, this);
|
|
449
|
-
} else {
|
|
450
|
-
this.maps.on(Browser.touchMoveEvent, this.renderTooltip, this);
|
|
451
|
-
}
|
|
452
|
-
this.maps.on(Browser.touchCancelEvent, this.removeTooltip, this);
|
|
453
|
-
this.maps.element.addEventListener('contextmenu', this.removeTooltip);
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Removes the event listeners.
|
|
457
|
-
*
|
|
458
|
-
* @returns {void}
|
|
459
|
-
* @private
|
|
460
|
-
*/
|
|
461
|
-
public removeEventListener(): void {
|
|
462
|
-
if (this.maps.isDestroyed) {
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (this.maps.tooltipDisplayMode === 'DoubleClick') {
|
|
466
|
-
this.maps.off('dblclick', this.renderTooltip);
|
|
467
|
-
} else if (this.maps.tooltipDisplayMode === 'Click') {
|
|
468
|
-
this.maps.off(Browser.touchEndEvent, this.mouseUpHandler);
|
|
469
|
-
} else {
|
|
470
|
-
this.maps.off(Browser.touchMoveEvent, this.renderTooltip);
|
|
471
|
-
}
|
|
472
|
-
this.maps.off(Browser.touchCancelEvent, this.removeTooltip);
|
|
473
|
-
this.maps.element.removeEventListener('contextmenu', this.removeTooltip);
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Get module name.
|
|
477
|
-
*
|
|
478
|
-
* @returns {string} Returns the module name
|
|
479
|
-
*/
|
|
480
|
-
protected getModuleName(): string {
|
|
481
|
-
return 'MapsTooltip';
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* To destroy the tooltip.
|
|
485
|
-
*
|
|
486
|
-
* @returns {void}
|
|
487
|
-
* @private
|
|
488
|
-
*/
|
|
489
|
-
public destroy(): void {
|
|
490
|
-
if (!isNullOrUndefined(this.svgTooltip)) {
|
|
491
|
-
this.svgTooltip.destroy();
|
|
492
|
-
this.svgTooltip.controlInstance = null;
|
|
493
|
-
removeElement(this.maps.element.id + '_mapsTooltip');
|
|
494
|
-
}
|
|
495
|
-
this.svgTooltip = null;
|
|
496
|
-
if (!(this.maps as any).refreshing) {
|
|
497
|
-
this.maps = null;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
}
|