@syncfusion/ej2-maps 19.4.53 → 19.4.56-105067
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -422
- 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 +1220 -653
- package/dist/es6/ej2-maps.es2015.js.map +1 -1
- package/dist/es6/ej2-maps.es5.js +1258 -692
- 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 +25 -3
- package/src/maps/maps.js +179 -106
- 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 +34 -33
- package/src/maps/model/export-pdf.d.ts +4 -6
- package/src/maps/model/export-pdf.js +31 -32
- package/src/maps/model/interface.d.ts +34 -26
- package/src/maps/model/print.d.ts +2 -5
- package/src/maps/model/print.js +32 -18
- 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 +9 -1
- package/src/maps/utils/helper.js +82 -33
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable jsdoc/require-param */
|
|
3
|
+
import { Maps, IAnnotationRenderingEventArgs, annotationRendering, Annotation } from '../index';
|
|
4
|
+
import { createElement, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
5
|
+
import { getTemplateFunction, Size, getElementOffset, getElementByID } from '../utils/helper';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents the annotation elements for map.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export class Annotations {
|
|
12
|
+
|
|
13
|
+
private map: Maps;
|
|
14
|
+
constructor(map: Maps) {
|
|
15
|
+
this.map = map;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public renderAnnotationElements(): void {
|
|
19
|
+
const secondaryID: string = this.map.element.id + '_Secondary_Element';
|
|
20
|
+
const annotationGroup: HTMLElement = createElement('div', { id: this.map.element.id + '_Annotations_Group' });
|
|
21
|
+
annotationGroup.style.position = 'absolute';
|
|
22
|
+
annotationGroup.style.top = '0px';
|
|
23
|
+
annotationGroup.style.left = '0px';
|
|
24
|
+
this.map.annotations.map((annotation: Annotation, index: number): void => {
|
|
25
|
+
if (annotation.content !== null) {
|
|
26
|
+
this.createAnnotationTemplate(annotationGroup, annotation, index);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (annotationGroup.childElementCount > 0 && !(isNullOrUndefined(getElementByID(secondaryID)))) {
|
|
30
|
+
getElementByID(secondaryID).appendChild(annotationGroup);
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
(this.map as any).renderReactTemplates();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line valid-jsdoc
|
|
37
|
+
/**
|
|
38
|
+
* To create annotation elements
|
|
39
|
+
*/
|
|
40
|
+
public createAnnotationTemplate(parentElement: HTMLElement, annotation: Annotation, annotationIndex: number): void {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
let left: number; let top: number; let templateFn: any;
|
|
43
|
+
const map: Maps = this.map; let templateElement: HTMLCollection;
|
|
44
|
+
const availSize: Size = map.availableSize;
|
|
45
|
+
const id: string = map.element.id + '_Annotation_' + annotationIndex;
|
|
46
|
+
const childElement: HTMLElement = createElement('div', {
|
|
47
|
+
id: map.element.id + '_Annotation_' + annotationIndex, styles: 'position: absolute; z-index:' + annotation.zIndex + ';'
|
|
48
|
+
});
|
|
49
|
+
const argsData: IAnnotationRenderingEventArgs = {
|
|
50
|
+
cancel: false, name: annotationRendering, content: annotation.content,
|
|
51
|
+
annotation: annotation
|
|
52
|
+
};
|
|
53
|
+
this.map.trigger(annotationRendering, argsData, (annotationArgs: IAnnotationRenderingEventArgs) => {
|
|
54
|
+
if (argsData.cancel) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
templateFn = getTemplateFunction(argsData.content, this.map);
|
|
58
|
+
if (templateFn && templateFn(
|
|
59
|
+
this.map, this.map, argsData.content, this.map.element.id + '_ContentTemplate_' + annotationIndex).length) {
|
|
60
|
+
templateElement = Array.prototype.slice.call(templateFn(
|
|
61
|
+
this.map, this.map, argsData.content, this.map.element.id + '_ContentTemplate_' + annotationIndex));
|
|
62
|
+
const length: number = templateElement.length;
|
|
63
|
+
for (let i: number = 0; i < length; i++) {
|
|
64
|
+
childElement.appendChild(templateElement[i]);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
childElement.appendChild(createElement('div', {
|
|
68
|
+
innerHTML: argsData.content
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const offset: Size = getElementOffset(<HTMLElement>childElement.cloneNode(true), map.element);
|
|
74
|
+
const elementRect: ClientRect = map.element.getBoundingClientRect();
|
|
75
|
+
const bounds: ClientRect = map.svgObject.getBoundingClientRect();
|
|
76
|
+
left = Math.abs(bounds.left - elementRect.left);
|
|
77
|
+
top = Math.abs(bounds.top - elementRect.top);
|
|
78
|
+
const annotationXValue: number = (annotation.x.indexOf('%') > -1) ? (availSize.width / 100) * parseFloat(annotation.x) :
|
|
79
|
+
parseFloat(annotation.x);
|
|
80
|
+
const annotationYValue: number = (annotation.y.indexOf('%') > -1) ? (availSize.height / 100) * parseFloat(annotation.y) :
|
|
81
|
+
parseFloat(annotation.y);
|
|
82
|
+
left = (annotation.horizontalAlignment === 'None') ? (left + annotationXValue) : left;
|
|
83
|
+
top = (annotation.verticalAlignment === 'None') ? (top + annotationYValue) : top;
|
|
84
|
+
switch (annotation.verticalAlignment) {
|
|
85
|
+
case 'Near':
|
|
86
|
+
top = (top + annotationYValue);
|
|
87
|
+
break;
|
|
88
|
+
case 'Center':
|
|
89
|
+
top = (top + annotationYValue) + ((bounds.height / 2) - (offset.height / 2));
|
|
90
|
+
break;
|
|
91
|
+
case 'Far':
|
|
92
|
+
top = (top + bounds.height + annotationYValue) - offset.height;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
switch (annotation.horizontalAlignment) {
|
|
96
|
+
case 'Near':
|
|
97
|
+
left = (left + annotationXValue);
|
|
98
|
+
break;
|
|
99
|
+
case 'Center':
|
|
100
|
+
left = (left + annotationXValue) + ((bounds.width / 2) - (offset.width / 2));
|
|
101
|
+
break;
|
|
102
|
+
case 'Far':
|
|
103
|
+
left = (left + bounds.width + annotationXValue) - offset.width;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
childElement.style.left = left + 'px';
|
|
107
|
+
childElement.style.top = top + 'px';
|
|
108
|
+
parentElement.appendChild(childElement);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/*
|
|
112
|
+
* Get module name.
|
|
113
|
+
*/
|
|
114
|
+
protected getModuleName(): string {
|
|
115
|
+
return 'Annotations';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* To destroy the annotation.
|
|
119
|
+
*
|
|
120
|
+
* @returns {void}
|
|
121
|
+
* @private
|
|
122
|
+
*/
|
|
123
|
+
public destroy(): void {
|
|
124
|
+
this.map = null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/* eslint-disable jsdoc/require-param */
|
|
3
|
+
/* eslint-disable max-len */
|
|
4
|
+
import { Maps } from '../../index';
|
|
5
|
+
import { HighlightSettingsModel, ISelectionEventArgs, itemHighlight } from '../index';
|
|
6
|
+
import { Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
7
|
+
import { getElementsByClassName, getElement, removeClass, createStyle, customizeStyle, getTargetElement } from '../utils/helper';
|
|
8
|
+
import { BorderModel } from '../model/base-model';
|
|
9
|
+
/**
|
|
10
|
+
* Highlight module class
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export class Highlight {
|
|
14
|
+
private maps: Maps;
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
public highlightSettings: HighlightSettingsModel;
|
|
19
|
+
constructor(maps: Maps) {
|
|
20
|
+
this.maps = maps;
|
|
21
|
+
this.addEventListener();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* To bind events for highlight module
|
|
25
|
+
*
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
private addEventListener(): void {
|
|
29
|
+
if (this.maps.isDestroyed) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.maps.on(Browser.touchMoveEvent, this.mouseMove, this);
|
|
33
|
+
this.maps.on(Browser.touchStartEvent, this.mouseMove, this);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* To unbind events for highlight module
|
|
37
|
+
*
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
40
|
+
private removeEventListener(): void {
|
|
41
|
+
if (this.maps.isDestroyed) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.maps.off(Browser.touchMoveEvent, this.mouseMove);
|
|
45
|
+
this.maps.off(Browser.touchStartEvent, this.mouseMove);
|
|
46
|
+
}
|
|
47
|
+
// eslint-disable-next-line valid-jsdoc
|
|
48
|
+
/**
|
|
49
|
+
* Public method for highlight module
|
|
50
|
+
*/
|
|
51
|
+
public addHighlight(layerIndex: number, name: string, enable: boolean): void {
|
|
52
|
+
const targetEle: Element = getTargetElement(layerIndex, name, enable, this.maps);
|
|
53
|
+
if (enable) {
|
|
54
|
+
this.mapHighlight(targetEle, null, null);
|
|
55
|
+
} else {
|
|
56
|
+
removeClass(targetEle);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
private mouseMove(e: PointerEvent): void {
|
|
60
|
+
let targetEle: Element = <Element>e.target;
|
|
61
|
+
let layerIndex: number;
|
|
62
|
+
const isTouch: boolean = e.pointerType === 'touch' || e.pointerType === '2' || (e.type.indexOf('touch') > -1);
|
|
63
|
+
if ((targetEle.id.indexOf('LayerIndex') !== -1 || targetEle.id.indexOf('NavigationIndex') > -1) &&
|
|
64
|
+
targetEle.getAttribute('class') !== 'ShapeselectionMapStyle' && !isTouch &&
|
|
65
|
+
targetEle.getAttribute('class') !== 'MarkerselectionMapStyle' &&
|
|
66
|
+
targetEle.getAttribute('class') !== 'BubbleselectionMapStyle' &&
|
|
67
|
+
targetEle.getAttribute('class') !== 'navigationlineselectionMapStyle' &&
|
|
68
|
+
targetEle.getAttribute('class') !== 'LineselectionMapStyle') {
|
|
69
|
+
layerIndex = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
|
+
let shapeData: any;
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
let data: any;
|
|
74
|
+
let shapeIn: number;
|
|
75
|
+
let dataIndex: number;
|
|
76
|
+
if (targetEle.id.indexOf('shapeIndex') > -1) {
|
|
77
|
+
shapeIn = parseInt(targetEle.id.split('_shapeIndex_')[1].split('_')[0], 10);
|
|
78
|
+
shapeData = this.maps.layers[layerIndex].shapeData['features'] &&
|
|
79
|
+
!isNullOrUndefined(this.maps.layersCollection[layerIndex].layerData[shapeIn]) ?
|
|
80
|
+
this.maps.layersCollection[layerIndex].layerData[shapeIn]['property'] : null;
|
|
81
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
82
|
+
data = isNullOrUndefined(dataIndex) ? null : this.maps.layers[layerIndex].dataSource[dataIndex];
|
|
83
|
+
this.highlightSettings = this.maps.layers[layerIndex].highlightSettings;
|
|
84
|
+
} else if (targetEle.id.indexOf('BubbleIndex') > -1) {
|
|
85
|
+
const bubble: number = parseInt(targetEle.id.split('_BubbleIndex_')[1].split('_')[0], 10);
|
|
86
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
87
|
+
data = this.maps.layers[layerIndex].bubbleSettings[bubble].dataSource[dataIndex];
|
|
88
|
+
this.highlightSettings = this.maps.layers[layerIndex].bubbleSettings[bubble].highlightSettings;
|
|
89
|
+
} else if (targetEle.id.indexOf('MarkerIndex') > -1) {
|
|
90
|
+
const marker: number = parseInt(targetEle.id.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
91
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
92
|
+
data = this.maps.layers[layerIndex].markerSettings[marker].dataSource[dataIndex];
|
|
93
|
+
this.highlightSettings = this.maps.layers[layerIndex].markerSettings[marker].highlightSettings;
|
|
94
|
+
} else {
|
|
95
|
+
const index: number = parseInt(targetEle.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
96
|
+
layerIndex = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
97
|
+
shapeData = null;
|
|
98
|
+
data = {
|
|
99
|
+
latitude: this.maps.layers[layerIndex].navigationLineSettings[index].latitude,
|
|
100
|
+
longitude: this.maps.layers[layerIndex].navigationLineSettings[index].longitude
|
|
101
|
+
};
|
|
102
|
+
this.highlightSettings = this.maps.layers[layerIndex].navigationLineSettings[index].highlightSettings;
|
|
103
|
+
}
|
|
104
|
+
if (this.highlightSettings.enable) {
|
|
105
|
+
this.handleHighlight(targetEle, layerIndex, data, shapeData);
|
|
106
|
+
} else {
|
|
107
|
+
const element: Element = document.getElementsByClassName('highlightMapStyle')[0];
|
|
108
|
+
if (!isNullOrUndefined(element)) {
|
|
109
|
+
removeClass(element);
|
|
110
|
+
if (element.id.indexOf('NavigationIndex') > -1) {
|
|
111
|
+
const index: number = parseInt(element.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
112
|
+
const layerIndex: number = parseInt(element.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
113
|
+
element.setAttribute(
|
|
114
|
+
'stroke-width', this.maps.layers[layerIndex].navigationLineSettings[index].width.toString());
|
|
115
|
+
element.setAttribute('stroke', this.maps.layers[layerIndex].navigationLineSettings[index].color);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else if (getElementsByClassName('highlightMapStyle').length > 0) {
|
|
120
|
+
targetEle = <Element>getElementsByClassName('highlightMapStyle')[0];
|
|
121
|
+
if (targetEle.id.indexOf('NavigationIndex') > -1) {
|
|
122
|
+
const index: number = parseInt(targetEle.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
123
|
+
layerIndex = parseInt(targetEle.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
124
|
+
targetEle.setAttribute('stroke-width', this.maps.layers[layerIndex].navigationLineSettings[index].width.toString());
|
|
125
|
+
targetEle.setAttribute('stroke', this.maps.layers[layerIndex].navigationLineSettings[index].color);
|
|
126
|
+
}
|
|
127
|
+
removeClass(targetEle);
|
|
128
|
+
if (this.maps.legendSettings.visible && this.maps.legendModule) {
|
|
129
|
+
this.maps.legendModule.removeShapeHighlightCollection();
|
|
130
|
+
}
|
|
131
|
+
} else if ((targetEle.id.indexOf(this.maps.element.id + '_Legend_Shape_Index') !== -1 ||
|
|
132
|
+
targetEle.id.indexOf(this.maps.element.id + '_Legend_Index') !== -1) && this.maps.legendModule &&
|
|
133
|
+
this.maps.legendSettings.visible && targetEle.id.indexOf('_Text') === -1) {
|
|
134
|
+
this.maps.legendModule.legendHighLightAndSelection(targetEle, 'highlight');
|
|
135
|
+
} else {
|
|
136
|
+
if (this.maps.legendSettings.visible && this.maps.legendModule) {
|
|
137
|
+
this.maps.legendModule.removeLegendHighlightCollection();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @private
|
|
144
|
+
*/
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
146
|
+
public handleHighlight(targetElement: Element, layerIndex: number, data: any, shapeData: any): void {
|
|
147
|
+
if (this.maps.legendSettings.visible && targetElement.id.indexOf('_MarkerIndex_') === -1 && this.maps.legendModule
|
|
148
|
+
&& this.maps.legendSettings.type === 'Layers') {
|
|
149
|
+
this.maps.legendModule.shapeHighLightAndSelection(
|
|
150
|
+
targetElement, data, this.highlightSettings, 'highlight', layerIndex);
|
|
151
|
+
}
|
|
152
|
+
const selectHighLight: boolean = targetElement.id.indexOf('shapeIndex') > -1 && (this.maps.legendSettings.visible && this.maps.legendModule) ?
|
|
153
|
+
this.maps.legendModule.shapeToggled : true;
|
|
154
|
+
if (selectHighLight) {
|
|
155
|
+
this.mapHighlight(targetElement, shapeData, data);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
|
+
private mapHighlight(targetEle: Element, shapeData: any, data: any): void {
|
|
161
|
+
const layerIndex: number = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
162
|
+
let isMarkerSelect: boolean = false;
|
|
163
|
+
if (targetEle.id.indexOf('MarkerIndex') > -1) {
|
|
164
|
+
const marker: number = parseInt(targetEle.id.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
165
|
+
isMarkerSelect = this.maps.layers[layerIndex].markerSettings[marker].highlightSettings.enable;
|
|
166
|
+
}
|
|
167
|
+
const border: BorderModel = {
|
|
168
|
+
color: (targetEle.parentElement.id.indexOf('LineString') === -1) ? this.highlightSettings.border.color : (this.highlightSettings.fill || this.highlightSettings.border.color),
|
|
169
|
+
width: (targetEle.parentElement.id.indexOf('LineString') === -1) ? (this.highlightSettings.border.width / (isMarkerSelect ? 1 : this.maps.scale)) : (this.highlightSettings.border.width / this.maps.scale),
|
|
170
|
+
opacity: this.highlightSettings.border.opacity
|
|
171
|
+
};
|
|
172
|
+
const eventArgs: ISelectionEventArgs = {
|
|
173
|
+
opacity: this.highlightSettings.opacity,
|
|
174
|
+
fill: (targetEle.parentElement.id.indexOf('LineString') === -1) ? (targetEle.id.indexOf('NavigationIndex') === -1 ? !isNullOrUndefined(this.highlightSettings.fill)
|
|
175
|
+
? this.highlightSettings.fill : targetEle.getAttribute('fill') : 'none') : 'transparent',
|
|
176
|
+
border: border,
|
|
177
|
+
name: itemHighlight,
|
|
178
|
+
target: targetEle.id,
|
|
179
|
+
cancel: false,
|
|
180
|
+
shapeData: shapeData,
|
|
181
|
+
data: data,
|
|
182
|
+
maps: this.maps
|
|
183
|
+
};
|
|
184
|
+
this.maps.trigger(itemHighlight, eventArgs, () => {
|
|
185
|
+
eventArgs.border.opacity = isNullOrUndefined(this.highlightSettings.border.opacity) ? this.highlightSettings.opacity : this.highlightSettings.border.opacity;
|
|
186
|
+
this.highlightMap(targetEle, eventArgs);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
private highlightMap(targetEle: Element, eventArgs: ISelectionEventArgs): void {
|
|
190
|
+
let parentElement: Element;
|
|
191
|
+
let children: HTMLCollection;
|
|
192
|
+
if (targetEle.getAttribute('class') === 'highlightMapStyle') {
|
|
193
|
+
return;
|
|
194
|
+
} else {
|
|
195
|
+
if (getElementsByClassName('highlightMapStyle').length > 0) {
|
|
196
|
+
const elem: Element = <Element>getElementsByClassName('highlightMapStyle')[0];
|
|
197
|
+
removeClass(elem);
|
|
198
|
+
if (elem.id.indexOf('NavigationIndex') > -1) {
|
|
199
|
+
const index: number = parseInt(elem.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
200
|
+
const layerIndex: number = parseInt(elem.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
201
|
+
elem.setAttribute('stroke-width', this.maps.layers[layerIndex].navigationLineSettings[index].width.toString());
|
|
202
|
+
elem.setAttribute('stroke', this.maps.layers[layerIndex].navigationLineSettings[index].color);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (!getElement('highlightMap')) {
|
|
206
|
+
document.body.appendChild(createStyle('highlightMap', 'highlightMapStyle', eventArgs));
|
|
207
|
+
} else {
|
|
208
|
+
customizeStyle('highlightMap', 'highlightMapStyle', eventArgs);
|
|
209
|
+
}
|
|
210
|
+
targetEle.setAttribute('class', 'highlightMapStyle');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get module name.
|
|
215
|
+
*
|
|
216
|
+
* @returns {string} - Specifies the module name
|
|
217
|
+
*/
|
|
218
|
+
protected getModuleName(): string {
|
|
219
|
+
return 'Highlight';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* To destroy the highlight.
|
|
224
|
+
*
|
|
225
|
+
* @returns {void}
|
|
226
|
+
* @private
|
|
227
|
+
*/
|
|
228
|
+
public destroy(): void {
|
|
229
|
+
this.highlightSettings = null;
|
|
230
|
+
this.removeEventListener();
|
|
231
|
+
this.maps = null;
|
|
232
|
+
}
|
|
233
|
+
}
|