@syncfusion/ej2-maps 30.2.4 → 31.2.2
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 +263 -0
- package/dist/ej2-maps.min.js +2 -2
- package/dist/ej2-maps.umd.min.js +2 -2
- package/dist/global/ej2-maps.min.js +2 -2
- package/dist/global/index.d.ts +2 -2
- package/dist/ts/index.d.ts +4 -0
- package/dist/ts/index.ts +4 -0
- package/dist/ts/maps/index.d.ts +28 -0
- package/dist/ts/maps/index.ts +28 -0
- package/dist/ts/maps/layers/bing-map.d.ts +21 -0
- package/dist/ts/maps/layers/bing-map.ts +51 -0
- package/dist/ts/maps/layers/bubble.d.ts +77 -0
- package/dist/ts/maps/layers/bubble.ts +304 -0
- package/dist/ts/maps/layers/color-mapping.d.ts +36 -0
- package/dist/ts/maps/layers/color-mapping.ts +230 -0
- package/dist/ts/maps/layers/data-label.d.ts +45 -0
- package/dist/ts/maps/layers/data-label.ts +457 -0
- package/dist/ts/maps/layers/layer-panel.d.ts +144 -0
- package/dist/ts/maps/layers/layer-panel.ts +1455 -0
- package/dist/ts/maps/layers/legend.d.ts +173 -0
- package/dist/ts/maps/layers/legend.ts +2465 -0
- package/dist/ts/maps/layers/marker.d.ts +105 -0
- package/dist/ts/maps/layers/marker.ts +632 -0
- package/dist/ts/maps/layers/navigation-selected-line.d.ts +33 -0
- package/dist/ts/maps/layers/navigation-selected-line.ts +171 -0
- package/dist/ts/maps/layers/polygon.d.ts +30 -0
- package/dist/ts/maps/layers/polygon.ts +68 -0
- package/dist/ts/maps/maps-model.d.ts +409 -0
- package/dist/ts/maps/maps.d.ts +1247 -0
- package/dist/ts/maps/maps.ts +3416 -0
- package/dist/ts/maps/model/base-model.d.ts +2107 -0
- package/dist/ts/maps/model/base.d.ts +1840 -0
- package/dist/ts/maps/model/base.ts +2257 -0
- package/dist/ts/maps/model/constants.d.ts +225 -0
- package/dist/ts/maps/model/constants.ts +226 -0
- package/dist/ts/maps/model/export-image.d.ts +39 -0
- package/dist/ts/maps/model/export-image.ts +194 -0
- package/dist/ts/maps/model/export-pdf.d.ts +40 -0
- package/dist/ts/maps/model/export-pdf.ts +183 -0
- package/dist/ts/maps/model/interface.d.ts +892 -0
- package/dist/ts/maps/model/interface.ts +929 -0
- package/dist/ts/maps/model/print.d.ts +45 -0
- package/dist/ts/maps/model/print.ts +125 -0
- package/dist/ts/maps/model/theme.d.ts +98 -0
- package/dist/ts/maps/model/theme.ts +919 -0
- package/dist/ts/maps/user-interaction/annotation.d.ts +27 -0
- package/dist/ts/maps/user-interaction/annotation.ts +133 -0
- package/dist/ts/maps/user-interaction/highlight.d.ts +63 -0
- package/dist/ts/maps/user-interaction/highlight.ts +272 -0
- package/dist/ts/maps/user-interaction/selection.d.ts +85 -0
- package/dist/ts/maps/user-interaction/selection.ts +342 -0
- package/dist/ts/maps/user-interaction/tooltip.d.ts +78 -0
- package/dist/ts/maps/user-interaction/tooltip.ts +500 -0
- package/dist/ts/maps/user-interaction/zoom.d.ts +334 -0
- package/dist/ts/maps/user-interaction/zoom.ts +2523 -0
- package/dist/ts/maps/utils/enum.d.ts +328 -0
- package/dist/ts/maps/utils/enum.ts +343 -0
- package/dist/ts/maps/utils/helper.d.ts +1318 -0
- package/dist/ts/maps/utils/helper.ts +3811 -0
- package/package.json +53 -18
- package/tslint.json +111 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Maps, Annotation } from '../index';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the annotation elements for map.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Annotations {
|
|
6
|
+
private map;
|
|
7
|
+
constructor(map: Maps);
|
|
8
|
+
renderAnnotationElements(): void;
|
|
9
|
+
/**
|
|
10
|
+
* To create annotation elements.
|
|
11
|
+
*
|
|
12
|
+
* @param {HTMLElement} parentElement - Specifies the parent element in the map.
|
|
13
|
+
* @param {Annotation} annotation - Specifies the options for customizing the annotation element in maps.
|
|
14
|
+
* @param {number} annotationIndex - Specifies the index of the annotation.
|
|
15
|
+
* @returns {void}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
createAnnotationTemplate(parentElement: HTMLElement, annotation: Annotation, annotationIndex: number): void;
|
|
19
|
+
protected getModuleName(): string;
|
|
20
|
+
/**
|
|
21
|
+
* To destroy the annotation.
|
|
22
|
+
*
|
|
23
|
+
* @returns {void}
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Maps, IAnnotationRenderingEventArgs, annotationRendering, Annotation } from '../index';
|
|
2
|
+
import { createElement, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
3
|
+
import { getTemplateFunction, Size, getElementOffset, getElementByID } from '../utils/helper';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents the annotation elements for map.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export class Annotations {
|
|
10
|
+
|
|
11
|
+
private map: Maps;
|
|
12
|
+
constructor(map: Maps) {
|
|
13
|
+
this.map = map;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public renderAnnotationElements(): void {
|
|
17
|
+
const secondaryID: string = this.map.element.id + '_Secondary_Element';
|
|
18
|
+
const annotationGroup: HTMLElement = createElement('div', { id: this.map.element.id + '_Annotations_Group' });
|
|
19
|
+
annotationGroup.style.position = 'absolute';
|
|
20
|
+
annotationGroup.style.top = '0px';
|
|
21
|
+
annotationGroup.style.left = '0px';
|
|
22
|
+
this.map.annotations.map((annotation: Annotation, index: number): void => {
|
|
23
|
+
if (annotation.content !== null) {
|
|
24
|
+
this.createAnnotationTemplate(annotationGroup, annotation, index);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (annotationGroup.childElementCount > 0 && !(isNullOrUndefined(getElementByID(secondaryID)))) {
|
|
28
|
+
getElementByID(secondaryID).appendChild(annotationGroup);
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
(this.map as any).renderReactTemplates();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* To create annotation elements.
|
|
36
|
+
*
|
|
37
|
+
* @param {HTMLElement} parentElement - Specifies the parent element in the map.
|
|
38
|
+
* @param {Annotation} annotation - Specifies the options for customizing the annotation element in maps.
|
|
39
|
+
* @param {number} annotationIndex - Specifies the index of the annotation.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
public createAnnotationTemplate(parentElement: HTMLElement, annotation: Annotation, annotationIndex: number): void {
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
let left: number; let top: number; let templateFn: any;
|
|
46
|
+
const map: Maps = this.map; let templateElement: HTMLCollection;
|
|
47
|
+
const availSize: Size = map.availableSize;
|
|
48
|
+
const childElement: HTMLElement = createElement('div', {
|
|
49
|
+
id: map.element.id + '_Annotation_' + annotationIndex
|
|
50
|
+
});
|
|
51
|
+
childElement.style.cssText = 'position: absolute; z-index:' + annotation.zIndex + ';';
|
|
52
|
+
const argsData: IAnnotationRenderingEventArgs = {
|
|
53
|
+
cancel: false, name: annotationRendering, content: annotation.content,
|
|
54
|
+
annotation: annotation
|
|
55
|
+
};
|
|
56
|
+
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
+
this.map.trigger(annotationRendering, argsData, (annotationArgs: IAnnotationRenderingEventArgs) => {
|
|
58
|
+
if (argsData.cancel) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
templateFn = getTemplateFunction(argsData.content, this.map);
|
|
62
|
+
if (templateFn && templateFn(
|
|
63
|
+
this.map, this.map, argsData.content, this.map.element.id + '_ContentTemplate_' + annotationIndex).length) {
|
|
64
|
+
templateElement = Array.prototype.slice.call(templateFn(
|
|
65
|
+
this.map, this.map, argsData.content, this.map.element.id + '_ContentTemplate_' + annotationIndex));
|
|
66
|
+
const length: number = templateElement.length;
|
|
67
|
+
for (let i: number = 0; i < length; i++) {
|
|
68
|
+
childElement.appendChild(templateElement[i as number]);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
childElement.appendChild(createElement('div', {
|
|
72
|
+
innerHTML: argsData.content as string
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const offset: Size = getElementOffset(<HTMLElement>childElement.cloneNode(true), map.element);
|
|
78
|
+
const elementRect: ClientRect = map.element.getBoundingClientRect();
|
|
79
|
+
const bounds: ClientRect = map.svgObject.getBoundingClientRect();
|
|
80
|
+
left = Math.abs(bounds.left - elementRect.left);
|
|
81
|
+
top = Math.abs(bounds.top - elementRect.top);
|
|
82
|
+
const annotationX: string = !isNullOrUndefined(annotation.x) ? annotation.x : '0%';
|
|
83
|
+
const annotationY: string = !isNullOrUndefined(annotation.y) ? annotation.y : '0%';
|
|
84
|
+
const annotationXValue: number = (annotationX.indexOf('%') > -1) ? (availSize.width / 100) * parseFloat(annotationX) :
|
|
85
|
+
parseFloat(annotationX);
|
|
86
|
+
const annotationYValue: number = (annotationY.indexOf('%') > -1) ? (availSize.height / 100) * parseFloat(annotationY) :
|
|
87
|
+
parseFloat(annotationY);
|
|
88
|
+
left = (annotation.horizontalAlignment === 'None') ? (left + annotationXValue) : left;
|
|
89
|
+
top = (annotation.verticalAlignment === 'None') ? (top + annotationYValue) : top;
|
|
90
|
+
switch (annotation.verticalAlignment) {
|
|
91
|
+
case 'Near':
|
|
92
|
+
top = (top + annotationYValue);
|
|
93
|
+
break;
|
|
94
|
+
case 'Center':
|
|
95
|
+
top = (top + annotationYValue) + ((bounds.height / 2) - (offset.height / 2));
|
|
96
|
+
break;
|
|
97
|
+
case 'Far':
|
|
98
|
+
top = (top + bounds.height + annotationYValue) - offset.height;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
switch (annotation.horizontalAlignment) {
|
|
102
|
+
case 'Near':
|
|
103
|
+
left = (left + annotationXValue);
|
|
104
|
+
break;
|
|
105
|
+
case 'Center':
|
|
106
|
+
left = (left + annotationXValue) + ((bounds.width / 2) - (offset.width / 2));
|
|
107
|
+
break;
|
|
108
|
+
case 'Far':
|
|
109
|
+
left = (left + bounds.width + annotationXValue) - offset.width;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
childElement.style.left = left + 'px';
|
|
113
|
+
childElement.style.top = top + 'px';
|
|
114
|
+
parentElement.appendChild(childElement);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* Get module name.
|
|
119
|
+
*/
|
|
120
|
+
protected getModuleName(): string {
|
|
121
|
+
return 'Annotations';
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* To destroy the annotation.
|
|
125
|
+
*
|
|
126
|
+
* @returns {void}
|
|
127
|
+
* @private
|
|
128
|
+
*/
|
|
129
|
+
public destroy(): void {
|
|
130
|
+
this.map = null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Maps } from '../../index';
|
|
2
|
+
import { HighlightSettingsModel } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* Highlight module class
|
|
5
|
+
*/
|
|
6
|
+
export declare class Highlight {
|
|
7
|
+
private maps;
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
highlightSettings: HighlightSettingsModel;
|
|
12
|
+
constructor(maps: Maps);
|
|
13
|
+
/**
|
|
14
|
+
* To bind events for highlight module.
|
|
15
|
+
*
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
private addEventListener;
|
|
19
|
+
/**
|
|
20
|
+
* To unbind events for highlight module.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
removeEventListener(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Public method for highlight module.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
30
|
+
* @param {string} name - Specifies the name.
|
|
31
|
+
* @param {boolean} enable - Specifies the enabling of highlight in map.
|
|
32
|
+
* @returns {void}
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
addHighlight(layerIndex: number, name: string, enable: boolean): void;
|
|
36
|
+
private mouseMove;
|
|
37
|
+
/**
|
|
38
|
+
* Handles the highlighting events in map.
|
|
39
|
+
*
|
|
40
|
+
* @param {Element} targetElement - Specifies the target element.
|
|
41
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
42
|
+
* @param {object} data - Specifies the data for the map.
|
|
43
|
+
* @param {object} shapeData - Specifies the data for the map to render.
|
|
44
|
+
* @returns {void}
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
handleHighlight(targetElement: Element, layerIndex: number, data: object, shapeData: object): void;
|
|
48
|
+
private mapHighlight;
|
|
49
|
+
private highlightMap;
|
|
50
|
+
/**
|
|
51
|
+
* Get module name.
|
|
52
|
+
*
|
|
53
|
+
* @returns {string} - Specifies the module name
|
|
54
|
+
*/
|
|
55
|
+
protected getModuleName(): string;
|
|
56
|
+
/**
|
|
57
|
+
* To destroy the highlight.
|
|
58
|
+
*
|
|
59
|
+
* @returns {void}
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
destroy(): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { Maps } from '../../index';
|
|
2
|
+
import { HighlightSettingsModel, ISelectionEventArgs, itemHighlight, shapeHighlight, IShapeSelectedEventArgs } from '../index';
|
|
3
|
+
import { Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
|
|
4
|
+
import { getElementsByClassName, getElement, removeClass, createStyle, customizeStyle, getTargetElement } from '../utils/helper';
|
|
5
|
+
/**
|
|
6
|
+
* Highlight module class
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export class Highlight {
|
|
10
|
+
private maps: Maps;
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
public highlightSettings: HighlightSettingsModel;
|
|
15
|
+
constructor(maps: Maps) {
|
|
16
|
+
this.maps = maps;
|
|
17
|
+
this.addEventListener();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* To bind events for highlight module.
|
|
21
|
+
*
|
|
22
|
+
* @returns {void}
|
|
23
|
+
*/
|
|
24
|
+
private addEventListener(): void {
|
|
25
|
+
if (this.maps.isDestroyed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.maps.on(Browser.touchMoveEvent, this.mouseMove, this);
|
|
29
|
+
this.maps.on(Browser.touchStartEvent, this.mouseMove, this);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* To unbind events for highlight module.
|
|
33
|
+
*
|
|
34
|
+
* @returns {void}
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
public removeEventListener(): void {
|
|
38
|
+
if (this.maps.isDestroyed) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.maps.off(Browser.touchMoveEvent, this.mouseMove);
|
|
42
|
+
this.maps.off(Browser.touchStartEvent, this.mouseMove);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Public method for highlight module.
|
|
46
|
+
*
|
|
47
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
48
|
+
* @param {string} name - Specifies the name.
|
|
49
|
+
* @param {boolean} enable - Specifies the enabling of highlight in map.
|
|
50
|
+
* @returns {void}
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
public addHighlight(layerIndex: number, name: string, enable: boolean): void {
|
|
54
|
+
const targetEle: Element = getTargetElement(layerIndex, name, enable, this.maps);
|
|
55
|
+
if (enable) {
|
|
56
|
+
this.mapHighlight(targetEle, null, null);
|
|
57
|
+
} else {
|
|
58
|
+
removeClass(targetEle);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
private mouseMove(e: PointerEvent): void {
|
|
62
|
+
let targetEle: Element = <Element>e.target;
|
|
63
|
+
let layerIndex: number;
|
|
64
|
+
const isTouch: boolean = e.pointerType === 'touch' || e.pointerType === '2' || (e.type.indexOf('touch') > -1);
|
|
65
|
+
if ((targetEle.id.indexOf('LayerIndex') !== -1 || targetEle.id.indexOf('NavigationIndex') > -1) &&
|
|
66
|
+
targetEle.getAttribute('class') !== 'ShapeselectionMapStyle' && !isTouch &&
|
|
67
|
+
targetEle.getAttribute('class') !== 'MarkerselectionMapStyle' &&
|
|
68
|
+
targetEle.getAttribute('class') !== 'BubbleselectionMapStyle' &&
|
|
69
|
+
targetEle.getAttribute('class') !== 'navigationlineselectionMapStyle' &&
|
|
70
|
+
targetEle.getAttribute('class') !== 'PolygonselectionMapStyle' &&
|
|
71
|
+
targetEle.getAttribute('class') !== 'LineselectionMapStyle') {
|
|
72
|
+
layerIndex = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
|
+
let shapeData: any;
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
|
+
let data: any;
|
|
77
|
+
let shapeIn: number;
|
|
78
|
+
let dataIndex: number;
|
|
79
|
+
if (targetEle.id.indexOf('shapeIndex') > -1) {
|
|
80
|
+
shapeIn = parseInt(targetEle.id.split('_shapeIndex_')[1].split('_')[0], 10);
|
|
81
|
+
shapeData = this.maps.layers[layerIndex as number].shapeData['features'] &&
|
|
82
|
+
!isNullOrUndefined(this.maps.layersCollection[layerIndex as number].layerData[shapeIn as number]) ?
|
|
83
|
+
this.maps.layersCollection[layerIndex as number].layerData[shapeIn as number]['property'] : null;
|
|
84
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
85
|
+
data = isNullOrUndefined(dataIndex) ? null : this.maps.layers[layerIndex as number].dataSource[dataIndex as number];
|
|
86
|
+
this.highlightSettings = this.maps.layers[layerIndex as number].highlightSettings;
|
|
87
|
+
} else if (targetEle.id.indexOf('BubbleIndex') > -1) {
|
|
88
|
+
const bubble: number = parseInt(targetEle.id.split('_BubbleIndex_')[1].split('_')[0], 10);
|
|
89
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
90
|
+
data = this.maps.layers[layerIndex as number].bubbleSettings[bubble as number].dataSource[dataIndex as number];
|
|
91
|
+
this.highlightSettings = this.maps.layers[layerIndex as number].bubbleSettings[bubble as number].highlightSettings;
|
|
92
|
+
} else if (targetEle.id.indexOf('MarkerIndex') > -1) {
|
|
93
|
+
const marker: number = parseInt(targetEle.id.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
94
|
+
dataIndex = parseInt(targetEle.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
95
|
+
data = this.maps.layers[layerIndex as number].markerSettings[marker as number].dataSource[dataIndex as number];
|
|
96
|
+
this.highlightSettings = this.maps.layers[layerIndex as number].markerSettings[marker as number].highlightSettings;
|
|
97
|
+
} else if (targetEle.id.indexOf('_PolygonIndex_') > -1) {
|
|
98
|
+
dataIndex = parseInt(targetEle.id.split('_PolygonIndex_')[1].split('_')[0], 10);
|
|
99
|
+
data = this.maps.layers[layerIndex as number].polygonSettings.polygons[dataIndex as number].points;
|
|
100
|
+
this.highlightSettings = this.maps.layers[layerIndex as number].polygonSettings.highlightSettings;
|
|
101
|
+
} else {
|
|
102
|
+
const index: number = parseInt(targetEle.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
103
|
+
layerIndex = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
104
|
+
shapeData = null;
|
|
105
|
+
data = {
|
|
106
|
+
latitude: this.maps.layers[layerIndex as number].navigationLineSettings[index as number].latitude,
|
|
107
|
+
longitude: this.maps.layers[layerIndex as number].navigationLineSettings[index as number].longitude
|
|
108
|
+
};
|
|
109
|
+
this.highlightSettings = this.maps.layers[layerIndex as number].navigationLineSettings[index as number].highlightSettings;
|
|
110
|
+
}
|
|
111
|
+
if (this.highlightSettings.enable) {
|
|
112
|
+
this.handleHighlight(targetEle, layerIndex, data, shapeData);
|
|
113
|
+
} else {
|
|
114
|
+
const element: Element = document.getElementsByClassName('highlightMapStyle')[0];
|
|
115
|
+
if (!isNullOrUndefined(element)) {
|
|
116
|
+
removeClass(element);
|
|
117
|
+
if (element.id.indexOf('NavigationIndex') > -1) {
|
|
118
|
+
const index: number = parseInt(element.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
119
|
+
const layerIndex: number = parseInt(element.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
120
|
+
element.setAttribute(
|
|
121
|
+
'stroke-width', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].width.toString());
|
|
122
|
+
element.setAttribute('stroke', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].color);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
} else if (getElementsByClassName('highlightMapStyle').length > 0) {
|
|
127
|
+
targetEle = <Element>getElementsByClassName('highlightMapStyle')[0];
|
|
128
|
+
if (targetEle.id.indexOf('NavigationIndex') > -1) {
|
|
129
|
+
const index: number = parseInt(targetEle.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
130
|
+
layerIndex = parseInt(targetEle.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
131
|
+
targetEle.setAttribute('stroke-width', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].width.toString());
|
|
132
|
+
targetEle.setAttribute('stroke', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].color);
|
|
133
|
+
}
|
|
134
|
+
removeClass(targetEle);
|
|
135
|
+
if (this.maps.legendSettings.visible && this.maps.legendModule) {
|
|
136
|
+
this.maps.legendModule.removeShapeHighlightCollection();
|
|
137
|
+
}
|
|
138
|
+
} else if ((targetEle.id.indexOf(this.maps.element.id + '_Legend_Shape_Index') !== -1 ||
|
|
139
|
+
targetEle.id.indexOf(this.maps.element.id + '_Legend_Index') !== -1) && this.maps.legendModule &&
|
|
140
|
+
this.maps.legendSettings.visible && targetEle.id.indexOf('_Text') === -1) {
|
|
141
|
+
this.maps.legendModule.legendHighLightAndSelection(targetEle, 'highlight');
|
|
142
|
+
} else {
|
|
143
|
+
if (this.maps.legendSettings.visible && this.maps.legendModule) {
|
|
144
|
+
this.maps.legendModule.removeLegendHighlightCollection();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Handles the highlighting events in map.
|
|
151
|
+
*
|
|
152
|
+
* @param {Element} targetElement - Specifies the target element.
|
|
153
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
154
|
+
* @param {object} data - Specifies the data for the map.
|
|
155
|
+
* @param {object} shapeData - Specifies the data for the map to render.
|
|
156
|
+
* @returns {void}
|
|
157
|
+
* @private
|
|
158
|
+
*/
|
|
159
|
+
public handleHighlight(targetElement: Element, layerIndex: number, data: object, shapeData: object): void {
|
|
160
|
+
if (this.maps.legendSettings.visible && targetElement.id.indexOf('_MarkerIndex_') === -1 && this.maps.legendModule
|
|
161
|
+
&& this.maps.legendSettings.type === 'Layers') {
|
|
162
|
+
this.maps.legendModule.shapeHighLightAndSelection(
|
|
163
|
+
targetElement, data, this.highlightSettings, 'highlight', layerIndex);
|
|
164
|
+
}
|
|
165
|
+
const selectHighLight: boolean = targetElement.id.indexOf('shapeIndex') > -1 && (this.maps.legendSettings.visible && this.maps.legendModule) ?
|
|
166
|
+
this.maps.legendModule.shapeToggled : true;
|
|
167
|
+
if (selectHighLight) {
|
|
168
|
+
this.mapHighlight(targetElement, shapeData, data);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
173
|
+
private mapHighlight(targetEle: Element, shapeData: any, data: any): void {
|
|
174
|
+
const layerIndex: number = parseInt(targetEle.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
175
|
+
let isMarkerSelect: boolean = false;
|
|
176
|
+
if (targetEle.id.indexOf('MarkerIndex') > -1) {
|
|
177
|
+
const marker: number = parseInt(targetEle.id.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
178
|
+
isMarkerSelect = this.maps.layers[layerIndex as number].markerSettings[marker as number].highlightSettings.enable;
|
|
179
|
+
}
|
|
180
|
+
const borderColor: string = (targetEle.parentElement.id.indexOf('LineString') === -1) ? this.highlightSettings.border.color : (this.highlightSettings.fill || this.highlightSettings.border.color);
|
|
181
|
+
const borderWidth: number = (targetEle.parentElement.id.indexOf('LineString') === -1) ? (this.highlightSettings.border.width / (isMarkerSelect ? 1 : this.maps.scale)) : (this.highlightSettings.border.width / this.maps.scale);
|
|
182
|
+
const borderOpacity: number = isNullOrUndefined(this.highlightSettings.border.opacity) ? this.highlightSettings.opacity :
|
|
183
|
+
this.highlightSettings.border.opacity;
|
|
184
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
|
+
const eventArgs: any = {
|
|
186
|
+
opacity: this.highlightSettings.opacity,
|
|
187
|
+
fill: (targetEle.parentElement.id.indexOf('LineString') === -1) ? (targetEle.id.indexOf('NavigationIndex') === -1 ? !isNullOrUndefined(this.highlightSettings.fill)
|
|
188
|
+
? this.highlightSettings.fill : targetEle.getAttribute('fill') : 'none') : 'transparent',
|
|
189
|
+
border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
|
|
190
|
+
cancel: false
|
|
191
|
+
};
|
|
192
|
+
const shapeEventArgs: IShapeSelectedEventArgs = {
|
|
193
|
+
opacity: eventArgs.opacity,
|
|
194
|
+
fill: eventArgs.fill,
|
|
195
|
+
border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
|
|
196
|
+
name: shapeHighlight,
|
|
197
|
+
target: targetEle.id,
|
|
198
|
+
cancel: false,
|
|
199
|
+
shapeData: shapeData,
|
|
200
|
+
data: data,
|
|
201
|
+
maps: this.maps
|
|
202
|
+
};
|
|
203
|
+
if (targetEle.id.indexOf('shapeIndex') > -1) {
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
205
|
+
this.maps.trigger(shapeHighlight, shapeEventArgs, () => { });
|
|
206
|
+
}
|
|
207
|
+
const itemEventArgs: ISelectionEventArgs = {
|
|
208
|
+
opacity: eventArgs.opacity,
|
|
209
|
+
fill: eventArgs.fill,
|
|
210
|
+
border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
|
|
211
|
+
name: itemHighlight,
|
|
212
|
+
target: targetEle.id,
|
|
213
|
+
cancel: false,
|
|
214
|
+
shapeData: shapeData,
|
|
215
|
+
data: data,
|
|
216
|
+
maps: this.maps
|
|
217
|
+
};
|
|
218
|
+
this.maps.trigger(itemHighlight, itemEventArgs, () => {
|
|
219
|
+
itemEventArgs.cancel = eventArgs.cancel !== itemEventArgs.cancel ? itemEventArgs.cancel : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.cancel : eventArgs.cancel;
|
|
220
|
+
itemEventArgs.fill = eventArgs.fill !== itemEventArgs.fill ? itemEventArgs.fill : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.fill : eventArgs.fill;
|
|
221
|
+
itemEventArgs.opacity = eventArgs.opacity !== itemEventArgs.opacity ? itemEventArgs.opacity : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.opacity : eventArgs.opacity;
|
|
222
|
+
itemEventArgs.border.color = eventArgs.border.color !== itemEventArgs.border.color ? itemEventArgs.border.color : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.color : eventArgs.border.color;
|
|
223
|
+
itemEventArgs.border.width = eventArgs.border.width !== itemEventArgs.border.width ? itemEventArgs.border.width : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.width : eventArgs.border.width;
|
|
224
|
+
itemEventArgs.border.opacity = eventArgs.border.opacity !== itemEventArgs.border.opacity ? itemEventArgs.border.opacity : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.opacity : eventArgs.border.opacity;
|
|
225
|
+
this.highlightMap(targetEle, itemEventArgs);
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
private highlightMap(targetEle: Element, eventArgs: ISelectionEventArgs): void {
|
|
229
|
+
if (targetEle.getAttribute('class') === 'highlightMapStyle' || eventArgs.cancel) {
|
|
230
|
+
return;
|
|
231
|
+
} else {
|
|
232
|
+
if (getElementsByClassName('highlightMapStyle').length > 0) {
|
|
233
|
+
const elem: Element = <Element>getElementsByClassName('highlightMapStyle')[0];
|
|
234
|
+
removeClass(elem);
|
|
235
|
+
if (elem.id.indexOf('NavigationIndex') > -1) {
|
|
236
|
+
const index: number = parseInt(elem.id.split('_NavigationIndex_')[1].split('_')[0], 10);
|
|
237
|
+
const layerIndex: number = parseInt(elem.parentElement.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
238
|
+
elem.setAttribute('stroke-width', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].width.toString());
|
|
239
|
+
elem.setAttribute('stroke', this.maps.layers[layerIndex as number].navigationLineSettings[index as number].color);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (!getElement('highlightMap')) {
|
|
243
|
+
document.body.appendChild(createStyle('highlightMap', 'highlightMapStyle', eventArgs));
|
|
244
|
+
} else {
|
|
245
|
+
customizeStyle('highlightMap', 'highlightMapStyle', eventArgs);
|
|
246
|
+
}
|
|
247
|
+
targetEle.setAttribute('class', 'highlightMapStyle');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get module name.
|
|
252
|
+
*
|
|
253
|
+
* @returns {string} - Specifies the module name
|
|
254
|
+
*/
|
|
255
|
+
protected getModuleName(): string {
|
|
256
|
+
return 'Highlight';
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* To destroy the highlight.
|
|
261
|
+
*
|
|
262
|
+
* @returns {void}
|
|
263
|
+
* @private
|
|
264
|
+
*/
|
|
265
|
+
public destroy(): void {
|
|
266
|
+
this.highlightSettings = null;
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
|
+
if (!(this.maps as any).refreshing) {
|
|
269
|
+
this.maps = null;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Maps } from '../../index';
|
|
2
|
+
import { SelectionSettingsModel } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* Selection module class
|
|
5
|
+
*/
|
|
6
|
+
export declare class Selection {
|
|
7
|
+
private maps;
|
|
8
|
+
/**
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
selectionsettings: SelectionSettingsModel;
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
selectionType: string;
|
|
16
|
+
constructor(maps: Maps);
|
|
17
|
+
/**
|
|
18
|
+
* For binding events to selection module.
|
|
19
|
+
*
|
|
20
|
+
* @returns {void}
|
|
21
|
+
*/
|
|
22
|
+
private addEventListener;
|
|
23
|
+
/**
|
|
24
|
+
* For removing events from selection module.
|
|
25
|
+
*
|
|
26
|
+
* @returns {void}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
removeEventListener(): void;
|
|
30
|
+
private mouseClick;
|
|
31
|
+
/**
|
|
32
|
+
* Selects the element in the map.
|
|
33
|
+
*
|
|
34
|
+
* @param {Element} targetElement - Specifies the target element.
|
|
35
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
36
|
+
* @param {object} data - Specifies the data for the map.
|
|
37
|
+
* @param {object} shapeData - Specifies the data for the map to render.
|
|
38
|
+
* @returns {void}
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
selectElement(targetElement: Element, layerIndex: number, data: object, shapeData: object): void;
|
|
42
|
+
/**
|
|
43
|
+
* Public method for selection.
|
|
44
|
+
*
|
|
45
|
+
* @param {number} layerIndex - Specifies the index of the layer.
|
|
46
|
+
* @param {string} name - Specifies the name.
|
|
47
|
+
* @param {boolean} enable - Specifies the enabling of selection in map.
|
|
48
|
+
* @returns {void}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
addSelection(layerIndex: number, name: string, enable: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Method for selection.
|
|
54
|
+
*
|
|
55
|
+
* @param {Element} targetElement - Specifies the target element
|
|
56
|
+
* @param {any} shapeData - Specifies the shape data
|
|
57
|
+
* @param {any} data - Specifies the data
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
private selectMap;
|
|
61
|
+
/**
|
|
62
|
+
* Remove legend selection
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* Get module name.
|
|
66
|
+
*
|
|
67
|
+
* @param {Element} targetElement - Specifies the target element
|
|
68
|
+
* @returns {void}
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
removedSelectionList(targetElement: Element): void;
|
|
72
|
+
/**
|
|
73
|
+
* Get module name.
|
|
74
|
+
*
|
|
75
|
+
* @returns {string} - Returns the module name
|
|
76
|
+
*/
|
|
77
|
+
protected getModuleName(): string;
|
|
78
|
+
/**
|
|
79
|
+
* To destroy the selection.
|
|
80
|
+
*
|
|
81
|
+
* @returns {void}
|
|
82
|
+
* @private
|
|
83
|
+
*/
|
|
84
|
+
destroy(): void;
|
|
85
|
+
}
|