@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,2523 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
import { Maps, Orientation, ITouches, ZoomSettings } from '../../index';
|
|
3
|
-
import { Point, getElementByID, Size, PathOption, Rect, convertGeoToPoint, CircleOption, convertTileLatLongToPoint, measureTextElement } from '../utils/helper';
|
|
4
|
-
import { RectOption, createTooltip, calculateScale, getTouchCenter, getTouches, targetTouches, Coordinate } from '../utils/helper';
|
|
5
|
-
import { MapLocation, zoomAnimate, smoothTranslate , measureText, textTrim, clusterTemplate, marker, getProcessedMarginValue } from '../utils/helper';
|
|
6
|
-
import { markerTemplate, removeElement, getElement, clusterSeparate, markerColorChoose, calculatePolygonPath } from '../utils/helper';
|
|
7
|
-
import { markerShapeChoose } from '../utils/helper';
|
|
8
|
-
import { isNullOrUndefined, EventHandler, Browser, remove, createElement, animationMode } from '@syncfusion/ej2-base';
|
|
9
|
-
import { MarkerSettings, LayerSettings, changeBorderWidth, IMarkerRenderingEventArgs, markerRendering} from '../index';
|
|
10
|
-
import { IMapZoomEventArgs, IMapPanEventArgs, IMinMaxLatitudeLongitude, GeoPosition } from '../model/interface';
|
|
11
|
-
import { pan } from '../model/constants';
|
|
12
|
-
import { getValueFromObject } from '../utils/helper';
|
|
13
|
-
import { PanDirection } from '../utils/enum';
|
|
14
|
-
import { FontModel, DataLabelSettingsModel, BorderModel, ZoomToolbarButtonSettingsModel, ZoomToolbarTooltipSettingsModel, ZoomToolbarSettingsModel, PolygonSettingModel } from '../model/base-model';
|
|
15
|
-
import { MapsTooltip } from './tooltip';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Zoom module used to process the zoom for maps
|
|
19
|
-
*/
|
|
20
|
-
export class Zoom {
|
|
21
|
-
private maps: Maps;
|
|
22
|
-
/** @private */
|
|
23
|
-
public toolBarGroup: Element;
|
|
24
|
-
private currentToolbarEle: Element;
|
|
25
|
-
/** @private */
|
|
26
|
-
public zoomingRect: Rect;
|
|
27
|
-
/** @private */
|
|
28
|
-
public selectionColor: string;
|
|
29
|
-
private fillColor: string;
|
|
30
|
-
private zoomElements: Element;
|
|
31
|
-
private panElements: Element;
|
|
32
|
-
/** @private */
|
|
33
|
-
public isPanModeEnabled: boolean = false;
|
|
34
|
-
/** @private */
|
|
35
|
-
public mouseEnter: boolean = false;
|
|
36
|
-
/** @private */
|
|
37
|
-
public baseTranslatePoint: Point;
|
|
38
|
-
private wheelEvent: string;
|
|
39
|
-
private cancelEvent: string;
|
|
40
|
-
/** @private */
|
|
41
|
-
public currentScale: number;
|
|
42
|
-
/** @private */
|
|
43
|
-
public isTouch: boolean = false;
|
|
44
|
-
/** @private */
|
|
45
|
-
public rectZoomingStart: boolean = false;
|
|
46
|
-
/** @private */
|
|
47
|
-
public touchStartList: ITouches[] | TouchList;
|
|
48
|
-
/** @private */
|
|
49
|
-
public touchMoveList: ITouches[] | TouchList;
|
|
50
|
-
/** @private */
|
|
51
|
-
public previousTouchMoveList: ITouches[] | TouchList;
|
|
52
|
-
/** @private */
|
|
53
|
-
public mouseDownPoints: Point;
|
|
54
|
-
/** @private */
|
|
55
|
-
public mouseMovePoints: Point;
|
|
56
|
-
/** @private */
|
|
57
|
-
public isDragZoom: boolean;
|
|
58
|
-
/** @private */
|
|
59
|
-
public currentLayer: LayerSettings;
|
|
60
|
-
private panColor: string;
|
|
61
|
-
private clearTimeout: number;
|
|
62
|
-
/** @private */
|
|
63
|
-
public zoomColor: string;
|
|
64
|
-
/** @private */
|
|
65
|
-
public browserName: string = Browser.info.name;
|
|
66
|
-
/** @private */
|
|
67
|
-
public isPointer: boolean = Browser.isPointer;
|
|
68
|
-
private handled: boolean = false;
|
|
69
|
-
private fingers: number;
|
|
70
|
-
/** @private */
|
|
71
|
-
public firstMove: boolean;
|
|
72
|
-
/** @private */
|
|
73
|
-
public isPanningInProgress: boolean = false;
|
|
74
|
-
private isPan: boolean = false;
|
|
75
|
-
private isZoomFinal: boolean = false;
|
|
76
|
-
private isZoomSelection: boolean = false;
|
|
77
|
-
private interaction: string;
|
|
78
|
-
private lastScale: number;
|
|
79
|
-
private pinchFactor: number = 1;
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
private startTouches: any[] = [];
|
|
82
|
-
private index: number;
|
|
83
|
-
private templateCount: number;
|
|
84
|
-
private pinchDistance: number;
|
|
85
|
-
/** @private */
|
|
86
|
-
public startDistance: number;
|
|
87
|
-
/** @private */
|
|
88
|
-
public touchCenter: Point;
|
|
89
|
-
/** @private */
|
|
90
|
-
public pinchStartLatLong: object;
|
|
91
|
-
/** @private */
|
|
92
|
-
public isCancellation: boolean = false;
|
|
93
|
-
private pinchTileZoomScale: number = 1;
|
|
94
|
-
private tileZoomLevel: number = 1;
|
|
95
|
-
private pinchZoomScale: number = 1;
|
|
96
|
-
private isPinchZooming: boolean = false;
|
|
97
|
-
|
|
98
|
-
/** @private */
|
|
99
|
-
public mouseDownLatLong: object = { x: 0, y: 0 };
|
|
100
|
-
/** @private */
|
|
101
|
-
public mouseMoveLatLong: object = { x: 0, y: 0 };
|
|
102
|
-
/** @private */
|
|
103
|
-
public isSingleClick: boolean = false;
|
|
104
|
-
/** @private */
|
|
105
|
-
public layerCollectionEle: Element;
|
|
106
|
-
constructor(maps: Maps) {
|
|
107
|
-
this.maps = maps;
|
|
108
|
-
this.wheelEvent = this.browserName === 'mozilla' ? (this.isPointer ? 'mousewheel' : 'DOMMouseScroll') : 'mousewheel';
|
|
109
|
-
this.cancelEvent = this.isPointer ? 'pointerleave' : 'mouseleave';
|
|
110
|
-
this.selectionColor = this.maps.zoomSettings.toolbarSettings.buttonSettings.selectionColor;
|
|
111
|
-
this.fillColor = this.maps.zoomSettings.toolbarSettings.buttonSettings.color;
|
|
112
|
-
this.addEventListener();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* To perform zooming for maps.
|
|
117
|
-
*
|
|
118
|
-
* @param {Point} position - Specifies the position.
|
|
119
|
-
* @param {number} newZoomFactor - Specifies the zoom factor.
|
|
120
|
-
* @param {string} type - Specifies the type.
|
|
121
|
-
* @param {boolean} isMouseWheel - Indicates whether the zoom operation was triggered by the mouse wheel.
|
|
122
|
-
* @returns {void}
|
|
123
|
-
* @private
|
|
124
|
-
*/
|
|
125
|
-
public performZooming(position: Point, newZoomFactor: number, type: string, isMouseWheel: boolean = false): void {
|
|
126
|
-
const map: Maps = this.maps;
|
|
127
|
-
map.previousProjection = newZoomFactor <= 1.5 ? undefined : map.projectionType;
|
|
128
|
-
map.defaultState = false;
|
|
129
|
-
map.initialCheck = false;
|
|
130
|
-
map.markerZoomedState = map.isMarkerZoomCompleted = false;
|
|
131
|
-
map.zoomPersistence = map.enablePersistence;
|
|
132
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
133
|
-
const maxZoom: number = map.zoomSettings.maxZoom;
|
|
134
|
-
const minZoom: number = map.zoomSettings.minZoom;
|
|
135
|
-
newZoomFactor = maxZoom >= newZoomFactor ? newZoomFactor : maxZoom; let isToolbarPerform: boolean = true;
|
|
136
|
-
switch (type.toLowerCase()) {
|
|
137
|
-
case 'zoomin':
|
|
138
|
-
isToolbarPerform = newZoomFactor <= this.maps.zoomSettings.maxZoom;
|
|
139
|
-
break;
|
|
140
|
-
case 'zoomout':
|
|
141
|
-
isToolbarPerform = newZoomFactor >= this.maps.zoomSettings.minZoom;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
if (isToolbarPerform) {
|
|
145
|
-
const scale: number = map.previousScale = map.scale;
|
|
146
|
-
const prevTilePoint: Point = map.tileTranslatePoint;
|
|
147
|
-
if ((!map.isTileMap) && ((type === 'ZoomIn' ? newZoomFactor >= minZoom && newZoomFactor <= maxZoom : newZoomFactor >= minZoom)
|
|
148
|
-
|| map.isReset)) {
|
|
149
|
-
const availSize: Rect = map.mapAreaRect;
|
|
150
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
-
const minBounds: any = map.baseMapRectBounds['min'] as any;
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
|
-
const maxBounds: any = map.baseMapRectBounds['max'] as any;
|
|
154
|
-
let mapTotalWidth: number = Math.abs(minBounds['x'] - maxBounds['x']);
|
|
155
|
-
let mapTotalHeight: number = Math.abs(minBounds['y'] - maxBounds['y']);
|
|
156
|
-
let translatePointX: number;
|
|
157
|
-
let translatePointY: number;
|
|
158
|
-
if (newZoomFactor < 1.2 && map.projectionType !== 'Eckert5') {
|
|
159
|
-
if (mapTotalWidth === 0 || mapTotalHeight === 0 || mapTotalWidth === mapTotalHeight) {
|
|
160
|
-
mapTotalWidth = availSize.width / 2;
|
|
161
|
-
mapTotalHeight = availSize.height;
|
|
162
|
-
}
|
|
163
|
-
newZoomFactor = parseFloat(Math.min(availSize.width / mapTotalWidth, availSize.height / mapTotalHeight).toFixed(2));
|
|
164
|
-
newZoomFactor = newZoomFactor > 1.05 ? 1 : newZoomFactor;
|
|
165
|
-
map.translatePoint = this.calculateInitalZoomTranslatePoint(newZoomFactor, mapTotalWidth, mapTotalHeight, availSize, minBounds, map);
|
|
166
|
-
} else {
|
|
167
|
-
const point: Point = map.translatePoint;
|
|
168
|
-
translatePointX = point.x - (((availSize.width / scale) - (availSize.width / newZoomFactor)) / (availSize.width / position.x));
|
|
169
|
-
translatePointY = point.y - (((availSize.height / scale) - (availSize.height / newZoomFactor)) / (availSize.height / position.y));
|
|
170
|
-
const currentHeight: number = Math.abs(map.baseMapRectBounds['max']['y'] - map.baseMapRectBounds['min']['y']) * newZoomFactor;
|
|
171
|
-
translatePointX = (currentHeight < map.mapAreaRect.height) ? (availSize.x + ((-(minBounds['x'])) + ((availSize.width / 2) - (mapTotalWidth / 2)))) : translatePointX;
|
|
172
|
-
translatePointY = (currentHeight < map.mapAreaRect.height) ? (availSize.y + ((-(minBounds['y'])) + ((availSize.height / 2) - (mapTotalHeight / 2)))) : translatePointY;
|
|
173
|
-
map.translatePoint = new Point(translatePointX, translatePointY);
|
|
174
|
-
}
|
|
175
|
-
map.scale = newZoomFactor;
|
|
176
|
-
map.zoomTranslatePoint = map.translatePoint;
|
|
177
|
-
if (this.triggerZoomEvent(prevTilePoint, prevLevel, type)) {
|
|
178
|
-
map.translatePoint = map.previousPoint;
|
|
179
|
-
map.scale = map.mapScaleValue = map.previousScale;
|
|
180
|
-
} else {
|
|
181
|
-
this.applyTransform(map, isMouseWheel);
|
|
182
|
-
}
|
|
183
|
-
} else if ((map.isTileMap) && (newZoomFactor >= minZoom && newZoomFactor <= maxZoom)) {
|
|
184
|
-
this.getTileTranslatePosition(prevLevel, newZoomFactor, position, type);
|
|
185
|
-
map.tileZoomLevel = newZoomFactor;
|
|
186
|
-
map.zoomSettings.zoomFactor = newZoomFactor;
|
|
187
|
-
map.scale = Math.pow(2, newZoomFactor - 1);
|
|
188
|
-
if (type === 'ZoomOut' && map.zoomSettings.resetToInitial && map.applyZoomReset && newZoomFactor <= map.initialZoomLevel) {
|
|
189
|
-
map.initialCheck = true;
|
|
190
|
-
map.zoomPersistence = false;
|
|
191
|
-
map.tileTranslatePoint.x = map.initialTileTranslate.x;
|
|
192
|
-
map.tileTranslatePoint.y = map.initialTileTranslate.y;
|
|
193
|
-
newZoomFactor = map.tileZoomLevel = map.mapScaleValue = map.initialZoomLevel;
|
|
194
|
-
map.scale = Math.pow(2, newZoomFactor - 1);
|
|
195
|
-
}
|
|
196
|
-
map.mapScaleValue = isNaN(map.mapScaleValue) ? 1 : map.mapScaleValue;
|
|
197
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - (0.01 * map.mapScaleValue)) / map.scale;
|
|
198
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - (0.01 * map.mapScaleValue)) / map.scale;
|
|
199
|
-
if (this.triggerZoomEvent(prevTilePoint, prevLevel, type)) {
|
|
200
|
-
map.translatePoint = map.tileTranslatePoint = new Point(0, 0);
|
|
201
|
-
map.scale = map.previousScale;
|
|
202
|
-
map.tileZoomLevel = prevLevel;
|
|
203
|
-
map.zoomSettings.zoomFactor = map.previousScale;
|
|
204
|
-
} else {
|
|
205
|
-
if (document.querySelector('.GroupElement')) {
|
|
206
|
-
(document.querySelector('.GroupElement') as HTMLElement).style.display = 'none';
|
|
207
|
-
}
|
|
208
|
-
if (document.getElementById(this.maps.element.id + '_LayerIndex_1')) {
|
|
209
|
-
document.getElementById(this.maps.element.id + '_LayerIndex_1').style.display = 'none';
|
|
210
|
-
}
|
|
211
|
-
this.markerLineAnimation(map);
|
|
212
|
-
map.mapLayerPanel.generateTiles(newZoomFactor, map.tileTranslatePoint, type + 'wheel', null, position);
|
|
213
|
-
const animationDuration: number = this.maps.layersCollection[0].animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.maps.layersCollection[0].animationDuration;
|
|
214
|
-
setTimeout(() => {
|
|
215
|
-
// if (type === 'ZoomOut') {
|
|
216
|
-
// element1.removeChild(element1.children[element1.childElementCount - 1]);
|
|
217
|
-
// if (element1.childElementCount) {
|
|
218
|
-
// element1.removeChild(element1.children[element1.childElementCount - 1]);
|
|
219
|
-
// } else {
|
|
220
|
-
// element1 = element1;
|
|
221
|
-
// }
|
|
222
|
-
// }
|
|
223
|
-
this.applyTransform(this.maps, isMouseWheel);
|
|
224
|
-
if (document.getElementById(this.maps.element.id + '_LayerIndex_1')) {
|
|
225
|
-
document.getElementById(this.maps.element.id + '_LayerIndex_1').style.display = 'block';
|
|
226
|
-
}
|
|
227
|
-
}, animationDuration);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
this.triggerZoomComplete(map, prevLevel, type);
|
|
231
|
-
}
|
|
232
|
-
this.maps.zoomNotApplied = false;
|
|
233
|
-
if (this.maps.isDevice) {
|
|
234
|
-
this.removeToolbarOpacity(map.isTileMap ? Math.round(map.tileZoomLevel) : map.scale, map.element.id + '_Zooming_');
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
|
-
private calculateInitalZoomTranslatePoint(newZoomFactor: number, mapTotalWidth: number, mapTotalHeight: number, availSize: Rect, minBounds: any, map: Maps): Point {
|
|
239
|
-
mapTotalWidth *= newZoomFactor;
|
|
240
|
-
mapTotalHeight *= newZoomFactor;
|
|
241
|
-
const widthDiff: number = minBounds['x'] !== 0 && map.translateType === 'layers' ? map.availableSize.width - availSize.width : 0;
|
|
242
|
-
const translatePointX: number = availSize.x + ((-(minBounds['x'])) + ((availSize.width / 2) - (mapTotalWidth / 2))) - widthDiff;
|
|
243
|
-
const translatePointY: number = availSize.y + ((-(minBounds['y'])) + ((availSize.height / 2) - (mapTotalHeight / 2)));
|
|
244
|
-
return new Point(translatePointX, translatePointY);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
private triggerZoomEvent(prevTilePoint: Point, prevLevel: number, type: string): boolean {
|
|
248
|
-
const map: Maps = this.maps; let zoomArgs: IMapZoomEventArgs;
|
|
249
|
-
if (map.isTileMap) {
|
|
250
|
-
map.mapScaleValue = isNullOrUndefined(map.mapScaleValue) ? 1 : map.mapScaleValue;
|
|
251
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - (0.01 * map.mapScaleValue)) / map.scale;
|
|
252
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - (0.01 * map.mapScaleValue)) / map.scale;
|
|
253
|
-
}
|
|
254
|
-
const minMaxLatitudeLongitude : IMinMaxLatitudeLongitude = this.maps.getMinMaxLatitudeLongitude();
|
|
255
|
-
if (!map.isTileMap) {
|
|
256
|
-
zoomArgs = {
|
|
257
|
-
cancel: false, name: 'zoom', type: type, maps: map,
|
|
258
|
-
tileTranslatePoint: {}, translatePoint: { previous: map.previousPoint, current: map.translatePoint },
|
|
259
|
-
tileZoomLevel: {}, scale: { previous: map.previousScale, current: map.scale },
|
|
260
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
261
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
262
|
-
};
|
|
263
|
-
} else {
|
|
264
|
-
zoomArgs = {
|
|
265
|
-
cancel: false, name: 'zoom', type: type, maps: map,
|
|
266
|
-
tileTranslatePoint: { previous: prevTilePoint, current: map.tileTranslatePoint }, translatePoint: { previous: map.previousPoint, current: map.translatePoint },
|
|
267
|
-
tileZoomLevel: { previous: prevLevel, current: map.tileZoomLevel }, scale: { previous: map.previousScale, current: map.scale },
|
|
268
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
269
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
map.trigger('zoom', zoomArgs);
|
|
273
|
-
return zoomArgs.cancel;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
private getTileTranslatePosition(prevLevel: number, currentLevel: number, position: Point, type?: string): void {
|
|
277
|
-
const map: Maps = this.maps;
|
|
278
|
-
const tileDefaultSize: number = 256;
|
|
279
|
-
const padding: number = type === 'ZoomOut' ? 10 : (type === 'Reset' && currentLevel > 1) ? 0 : 10;
|
|
280
|
-
const bounds: Size = map.availableSize;
|
|
281
|
-
const prevSize: number = Math.pow(2, prevLevel) * 256;
|
|
282
|
-
const totalSize: number = Math.pow(2, currentLevel) * 256;
|
|
283
|
-
const x: number = ((position.x - map.tileTranslatePoint.x) / prevSize) * 100;
|
|
284
|
-
const y: number = ((position.y - map.tileTranslatePoint.y) / prevSize) * 100;
|
|
285
|
-
map.tileTranslatePoint.x = (currentLevel === 1) ? (bounds.width / 2) - ((tileDefaultSize * 2) / 2) :
|
|
286
|
-
position.x - ((x * totalSize) / 100);
|
|
287
|
-
map.tileTranslatePoint.y = (currentLevel === 1) ? ((bounds.height / 2) - ((tileDefaultSize * 2) / 2) + (padding * 2)) :
|
|
288
|
-
position.y - ((y * totalSize) / 100);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
private getTileTranslate(currentLevel: number, type?: string): void {
|
|
292
|
-
const map: Maps = this.maps;
|
|
293
|
-
const padding: number = type === 'ZoomOut' ? 10 : (type === 'Reset' && currentLevel > 1) ? 0 : 10;
|
|
294
|
-
const bounds: Size = map.availableSize;
|
|
295
|
-
const totalSize: number = Math.pow(2, currentLevel) * 256;
|
|
296
|
-
let x: number = (bounds.width / 2) - (totalSize / 2);
|
|
297
|
-
let y: number = (bounds.height / 2) - (totalSize / 2);
|
|
298
|
-
const position: Point = convertTileLatLongToPoint(
|
|
299
|
-
new MapLocation(this.pinchStartLatLong['longitude'], this.pinchStartLatLong['latitude']), currentLevel, {x: x, y: y}, true
|
|
300
|
-
);
|
|
301
|
-
x -= position.x - (bounds.width / 2);
|
|
302
|
-
y = y - (position.y - (bounds.height / 2)) + padding;
|
|
303
|
-
const scale: number = Math.pow(2, currentLevel - 1);
|
|
304
|
-
map.tileTranslatePoint.x = x;
|
|
305
|
-
map.tileTranslatePoint.y = y;
|
|
306
|
-
map.translatePoint.x = (x - (0.01 * this.tileZoomLevel)) / scale;
|
|
307
|
-
map.translatePoint.y = (y - (0.01 * this.tileZoomLevel)) / scale;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* @returns {void}
|
|
312
|
-
* @private
|
|
313
|
-
*/
|
|
314
|
-
public performRectZooming(): void {
|
|
315
|
-
this.isDragZoom = true;
|
|
316
|
-
const map: Maps = this.maps;
|
|
317
|
-
const size: Size = map.availableSize;
|
|
318
|
-
map.previousProjection = map.projectionType;
|
|
319
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
320
|
-
const prevTilePoint: Point = map.tileTranslatePoint;
|
|
321
|
-
const zoomRect: Rect = this.zoomingRect;
|
|
322
|
-
const maxZoom: number = map.zoomSettings.maxZoom;
|
|
323
|
-
const minZoom: number = map.zoomSettings.minZoom;
|
|
324
|
-
let isZoomCancelled: boolean;
|
|
325
|
-
if (zoomRect.height > 0 && zoomRect.width > 0) {
|
|
326
|
-
const x: number = this.zoomingRect.x + (this.zoomingRect.width / 2);
|
|
327
|
-
const y: number = this.zoomingRect.y + (this.zoomingRect.height / 2);
|
|
328
|
-
let zoomCalculationFactor: number;
|
|
329
|
-
if (!map.isTileMap) {
|
|
330
|
-
const scale: number = map.previousScale = map.scale;
|
|
331
|
-
zoomCalculationFactor = scale + Math.round((((size.width / zoomRect.width) + (size.height / zoomRect.height)) / 2));
|
|
332
|
-
zoomCalculationFactor = zoomCalculationFactor < this.maps.zoomSettings.maxZoom ? zoomCalculationFactor : this.maps.zoomSettings.maxZoom;
|
|
333
|
-
const translatePoint: Point = map.previousPoint = map.translatePoint;
|
|
334
|
-
if (zoomCalculationFactor <= maxZoom) {
|
|
335
|
-
const translatePointX: number = translatePoint.x - (((size.width / scale) - (size.width / zoomCalculationFactor)) / (size.width / x));
|
|
336
|
-
const translatePointY: number = translatePoint.y - (((size.height / scale) - (size.height / zoomCalculationFactor)) / (size.height / y));
|
|
337
|
-
map.translatePoint = new Point(translatePointX, translatePointY);
|
|
338
|
-
}
|
|
339
|
-
map.scale = zoomCalculationFactor < this.maps.zoomSettings.maxZoom ? zoomCalculationFactor : this.maps.zoomSettings.maxZoom;
|
|
340
|
-
isZoomCancelled = this.triggerZoomEvent(prevTilePoint, prevLevel, '');
|
|
341
|
-
if (isZoomCancelled) {
|
|
342
|
-
map.translatePoint = map.previousPoint;
|
|
343
|
-
map.scale = map.previousScale;
|
|
344
|
-
}
|
|
345
|
-
map.zoomTranslatePoint = map.translatePoint;
|
|
346
|
-
} else {
|
|
347
|
-
zoomCalculationFactor = prevLevel + (Math.round(prevLevel + (((size.width / zoomRect.width) + (size.height / zoomRect.height)) / 2)));
|
|
348
|
-
zoomCalculationFactor = (zoomCalculationFactor >= minZoom && zoomCalculationFactor <= maxZoom) ? zoomCalculationFactor : maxZoom;
|
|
349
|
-
map.zoomSettings.zoomFactor = zoomCalculationFactor;
|
|
350
|
-
this.getTileTranslatePosition(prevLevel, zoomCalculationFactor, { x: x, y: y });
|
|
351
|
-
map.tileZoomLevel = zoomCalculationFactor;
|
|
352
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - (0.5 * Math.pow(2, zoomCalculationFactor))) /
|
|
353
|
-
(Math.pow(2, zoomCalculationFactor));
|
|
354
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - (0.5 * Math.pow(2, zoomCalculationFactor))) /
|
|
355
|
-
(Math.pow(2, zoomCalculationFactor));
|
|
356
|
-
map.scale = (Math.pow(2, zoomCalculationFactor));
|
|
357
|
-
isZoomCancelled = this.triggerZoomEvent(prevTilePoint, prevLevel, '');
|
|
358
|
-
if (isZoomCancelled) {
|
|
359
|
-
map.translatePoint = map.tileTranslatePoint = new Point(0, 0);
|
|
360
|
-
map.scale = map.tileZoomLevel = map.zoomSettings.zoomFactor = prevLevel;
|
|
361
|
-
} else {
|
|
362
|
-
map.mapLayerPanel.generateTiles(zoomCalculationFactor, map.tileTranslatePoint);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (!isZoomCancelled) {
|
|
366
|
-
map.mapScaleValue = zoomCalculationFactor;
|
|
367
|
-
this.applyTransform(map, false, true);
|
|
368
|
-
this.maps.zoomNotApplied = false;
|
|
369
|
-
this.zoomingRect = null;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
this.isZoomFinal = this.isZoomSelection && Math.round(map.scale) === this.maps.zoomSettings.maxZoom;
|
|
373
|
-
this.triggerZoomComplete(map, prevLevel, '');
|
|
374
|
-
this.removeToolbarOpacity(map.scale, this.maps.element.id + '_Zooming_');
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
private setInteraction(newInteraction: string): void {
|
|
378
|
-
this.lastScale = 1;
|
|
379
|
-
this.interaction = newInteraction;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
private updateInteraction(): void {
|
|
383
|
-
if (this.fingers === 2) {
|
|
384
|
-
this.setInteraction('zoom');
|
|
385
|
-
} else {
|
|
386
|
-
this.setInteraction(null);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
private tilePinchingProcess (scale: number): void {
|
|
391
|
-
this.tileZoomLevel = Math.round(scale);
|
|
392
|
-
this.getTileTranslate(this.tileZoomLevel);
|
|
393
|
-
this.maps.mapLayerPanel.generateTiles(this.tileZoomLevel, this.maps.tileTranslatePoint, null, null, null, true);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* @param {PointerEvent} e - Specifies the vent in the map
|
|
398
|
-
* @returns {void}
|
|
399
|
-
* @private
|
|
400
|
-
*/
|
|
401
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
402
|
-
public performPinchZooming(e: PointerEvent | TouchEvent): void {
|
|
403
|
-
const map: Maps = this.maps;
|
|
404
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
405
|
-
let zoomCalculationFactor: number = this.pinchFactor;
|
|
406
|
-
let isZoomCancelled: boolean;
|
|
407
|
-
const prevTilePoint: Point = map.tileTranslatePoint;
|
|
408
|
-
this.maps.mergeCluster();
|
|
409
|
-
if (!map.isTileMap) {
|
|
410
|
-
const availSize: Rect = map.mapAreaRect;
|
|
411
|
-
map.isMarkerZoomCompleted = false;
|
|
412
|
-
map.previousScale = map.scale;
|
|
413
|
-
map.previousPoint = map.translatePoint;
|
|
414
|
-
map.previousProjection = map.projectionType;
|
|
415
|
-
const scale: number = calculateScale(<ITouches[]>this.touchStartList, <ITouches[]>this.touchMoveList);
|
|
416
|
-
const touchCenter: Point = getTouchCenter(getTouches(<ITouches[]>this.touchMoveList, this.maps));
|
|
417
|
-
const newScale: number = scale / this.lastScale;
|
|
418
|
-
this.lastScale = scale;
|
|
419
|
-
this.pinchFactor *= newScale;
|
|
420
|
-
this.pinchFactor = Math.min(this.maps.zoomSettings.maxZoom, Math.max(this.pinchFactor, this.maps.zoomSettings.minZoom));
|
|
421
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
422
|
-
const minBounds: any = map.baseMapRectBounds['min'] as any;
|
|
423
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
424
|
-
const maxBounds: any = map.baseMapRectBounds['max'] as any;
|
|
425
|
-
let mapTotalHeight: number = Math.abs(minBounds['y'] - maxBounds['y']);
|
|
426
|
-
let mapTotalWidth: number = Math.abs(minBounds['x'] - maxBounds['x']);
|
|
427
|
-
const translatePoint: Point = map.translatePoint;
|
|
428
|
-
let translatePointX: number;
|
|
429
|
-
let translatePointY: number;
|
|
430
|
-
if (zoomCalculationFactor < 1.2 && map.projectionType !== 'Eckert5') {
|
|
431
|
-
if (mapTotalWidth === 0 || mapTotalHeight === 0 || mapTotalWidth === mapTotalHeight) {
|
|
432
|
-
mapTotalWidth = availSize.width / 2;
|
|
433
|
-
mapTotalHeight = availSize.height;
|
|
434
|
-
}
|
|
435
|
-
zoomCalculationFactor = parseFloat(Math.min(availSize.width / mapTotalWidth, availSize.height / mapTotalHeight).toFixed(2));
|
|
436
|
-
zoomCalculationFactor = zoomCalculationFactor > 1.05 ? 1 : zoomCalculationFactor;
|
|
437
|
-
map.translatePoint = this.calculateInitalZoomTranslatePoint(zoomCalculationFactor, mapTotalWidth, mapTotalHeight, availSize, minBounds, map);
|
|
438
|
-
}
|
|
439
|
-
else {
|
|
440
|
-
const currentHeight: number = Math.abs(map.baseMapRectBounds['max']['y'] - map.baseMapRectBounds['min']['y']) * zoomCalculationFactor;
|
|
441
|
-
translatePointX = translatePoint.x - (((availSize.width / map.scale) - (availSize.width / zoomCalculationFactor)) / (availSize.width / touchCenter.x));
|
|
442
|
-
translatePointY = translatePoint.y - (((availSize.height / map.scale) - (availSize.height / zoomCalculationFactor)) / (availSize.height / touchCenter.y));
|
|
443
|
-
translatePointX = (currentHeight < map.mapAreaRect.height) ? (availSize.x + ((-(minBounds['x'])) + ((availSize.width / 2) - (mapTotalWidth / 2)))) : translatePointX;
|
|
444
|
-
translatePointY = (currentHeight < map.mapAreaRect.height) ? (availSize.y + ((-(minBounds['y'])) + ((availSize.height / 2) - (mapTotalHeight / 2)))) : translatePointY;
|
|
445
|
-
map.translatePoint = new Point(translatePointX, translatePointY);
|
|
446
|
-
}
|
|
447
|
-
map.scale = zoomCalculationFactor;
|
|
448
|
-
isZoomCancelled = this.triggerZoomEvent(prevTilePoint, prevLevel, '');
|
|
449
|
-
if (isZoomCancelled) {
|
|
450
|
-
map.translatePoint = map.previousPoint;
|
|
451
|
-
map.scale = map.previousScale;
|
|
452
|
-
}
|
|
453
|
-
} else {
|
|
454
|
-
this.isPinchZooming = true;
|
|
455
|
-
const touchCenter: Point = this.touchCenter;
|
|
456
|
-
const touchOnePoint: MapLocation = this.getMousePosition(this.touchMoveList[0].pageX, this.touchMoveList[0].pageY);
|
|
457
|
-
const touchTwoPoint: MapLocation = this.getMousePosition(this.touchMoveList[1].pageX, this.touchMoveList[1].pageY);
|
|
458
|
-
const distance: number = Math.sqrt(Math.pow((touchOnePoint.x - touchTwoPoint.x), 2) + Math.pow((touchOnePoint.y - touchTwoPoint.y), 2));
|
|
459
|
-
const pinchScale: number = distance / this.startDistance;
|
|
460
|
-
if (!isNullOrUndefined(this.pinchDistance)) {
|
|
461
|
-
let pinchZoomFactor: number = Math.log2(pinchScale * (256 * Math.pow(2, prevLevel)) / 256);
|
|
462
|
-
pinchZoomFactor = Math.min(map.zoomSettings.maxZoom, Math.max(map.zoomSettings.minZoom, pinchZoomFactor));
|
|
463
|
-
const scaleFactor: number = this.pinchDistance > distance ? (prevLevel * pinchScale) : pinchZoomFactor;
|
|
464
|
-
let factor: number = pinchZoomFactor;
|
|
465
|
-
let isZoomOut: boolean = false;
|
|
466
|
-
if (this.pinchDistance > distance) {
|
|
467
|
-
factor = (scaleFactor % 1);
|
|
468
|
-
isZoomOut = true;
|
|
469
|
-
} else if (this.pinchDistance < distance) {
|
|
470
|
-
factor = (scaleFactor % 1) + 1;
|
|
471
|
-
}
|
|
472
|
-
const zoomFactor: number = Math.ceil(scaleFactor);
|
|
473
|
-
if (zoomFactor > map.zoomSettings.minZoom && zoomFactor <= map.zoomSettings.maxZoom) {
|
|
474
|
-
const element: HTMLElement = document.getElementById(map.element.id);
|
|
475
|
-
if (element) {
|
|
476
|
-
element.style.overflow = 'hidden';
|
|
477
|
-
}
|
|
478
|
-
this.tileZoomLevel = zoomFactor;
|
|
479
|
-
const transformOriginX: number = (touchCenter.x / (map.mapAreaRect.width - map.mapAreaRect.x)) * 100;
|
|
480
|
-
const transformOriginY: number = (touchCenter.y / (map.mapAreaRect.height - map.mapAreaRect.y)) * 100;
|
|
481
|
-
const tilesParent: HTMLElement = document.getElementById(map.element.id + '_tile_parent');
|
|
482
|
-
let copyTilesParent: HTMLElement = document.getElementById(map.element.id + '_tiles');
|
|
483
|
-
if (!copyTilesParent) {
|
|
484
|
-
copyTilesParent = document.createElement('div');
|
|
485
|
-
copyTilesParent.id = map.element.id + '_tiles';
|
|
486
|
-
map.element.appendChild(copyTilesParent);
|
|
487
|
-
this.copyStyles(tilesParent, copyTilesParent);
|
|
488
|
-
copyTilesParent.style.zIndex = '0';
|
|
489
|
-
}
|
|
490
|
-
copyTilesParent.style.visibility = 'hidden';
|
|
491
|
-
tilesParent.style.transformOrigin = `${transformOriginX}% ${transformOriginY}%`;
|
|
492
|
-
tilesParent.style.transform = `scale(${factor})`;
|
|
493
|
-
const svgElement: HTMLElement = document.getElementById(map.element.id + '_Tile_SVG_Parent');
|
|
494
|
-
svgElement.style.transformOrigin = `${transformOriginX}% ${transformOriginY}%`;
|
|
495
|
-
svgElement.style.transform = `scale(${factor})`;
|
|
496
|
-
if (!this.isCancellation && (0.2 >= scaleFactor % 1 && scaleFactor % 1 >= 0.1 && !isZoomOut) || (scaleFactor % 1 <= 0.9 && isZoomOut)) {
|
|
497
|
-
let animateTile: HTMLElement = document.getElementById(map.element.id + '_animates_tiles');
|
|
498
|
-
if (!animateTile) {
|
|
499
|
-
animateTile = document.createElement('div');
|
|
500
|
-
animateTile.id = map.element.id + '_animates_tiles';
|
|
501
|
-
animateTile.classList.add(this.tileZoomLevel.toString());
|
|
502
|
-
copyTilesParent.appendChild(animateTile);
|
|
503
|
-
}
|
|
504
|
-
if (animateTile.childElementCount === 0) {
|
|
505
|
-
this.pinchZoomScale = isZoomOut ? Math.floor(scaleFactor) : Math.ceil(scaleFactor);
|
|
506
|
-
this.tilePinchingProcess(this.pinchZoomScale);
|
|
507
|
-
this.isCancellation = true;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
if (this.isCancellation && (scaleFactor % 1 >= 0.99 && !isZoomOut) || (scaleFactor % 1 <= 0.1 && isZoomOut)) {
|
|
511
|
-
if (tilesParent.style.transformOrigin !== '' && this.isCancellation) {
|
|
512
|
-
tilesParent.style.transformOrigin = '';
|
|
513
|
-
tilesParent.style.transform = '';
|
|
514
|
-
svgElement.style.transformOrigin = '';
|
|
515
|
-
svgElement.style.transform = '';
|
|
516
|
-
this.pinchTileZoomScale = isZoomOut ? Math.floor(scaleFactor) : Math.ceil(scaleFactor);
|
|
517
|
-
this.getTileTranslate(this.pinchTileZoomScale);
|
|
518
|
-
const targetElement: HTMLElement = document.getElementById(map.element.id + '_animated_tiles');
|
|
519
|
-
const sourceElement: HTMLElement = document.getElementById(map.element.id + '_animates_tiles');
|
|
520
|
-
while (targetElement.firstChild) {
|
|
521
|
-
targetElement.removeChild(targetElement.firstChild);
|
|
522
|
-
}
|
|
523
|
-
Array.from(sourceElement.children).forEach((child: Element) => {
|
|
524
|
-
targetElement.appendChild(child.cloneNode(true));
|
|
525
|
-
});
|
|
526
|
-
document.getElementById(map.element.id + '_animated_tiles')['className'] = this.pinchTileZoomScale.toFixed(0);
|
|
527
|
-
if (sourceElement) {
|
|
528
|
-
while (sourceElement.firstChild) {
|
|
529
|
-
sourceElement.removeChild(sourceElement.firstChild);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
this.isCancellation = false;
|
|
533
|
-
map.mapScaleValue = this.pinchTileZoomScale;
|
|
534
|
-
map.scale = Math.pow(2, this.pinchTileZoomScale - 1);
|
|
535
|
-
this.applyTransform(map);
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
this.pinchDistance = distance;
|
|
541
|
-
}
|
|
542
|
-
if (!map.isTileMap) {
|
|
543
|
-
map.mapScaleValue = zoomCalculationFactor;
|
|
544
|
-
if (!isZoomCancelled) {
|
|
545
|
-
this.applyTransform(map);
|
|
546
|
-
}
|
|
547
|
-
this.triggerZoomComplete(map, prevLevel, '');
|
|
548
|
-
}
|
|
549
|
-
if (Browser.isDevice) {
|
|
550
|
-
this.removeToolbarOpacity(map.isTileMap ? Math.round(map.tileZoomLevel) : map.scale, map.element.id + '_Zooming_');
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
private copyStyles(sourceElement: HTMLElement, targetElement: HTMLElement): void {
|
|
555
|
-
const sourceStyles: CSSStyleDeclaration = window.getComputedStyle(sourceElement);
|
|
556
|
-
Array.from(sourceStyles).forEach((style: string) => {
|
|
557
|
-
targetElement.style[style as string] = sourceStyles.getPropertyValue(style);
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
private getTouchCenterPoint(): Point {
|
|
561
|
-
const touchList: Point[] = [];
|
|
562
|
-
for (let i: number = 0; i < this.touchMoveList.length; i++) {
|
|
563
|
-
touchList.push(this.getMousePosition(this.touchMoveList[i as number].pageX, this.touchMoveList[i as number].pageY));
|
|
564
|
-
}
|
|
565
|
-
return {
|
|
566
|
-
x: (touchList[0].x + touchList[1].x) / 2,
|
|
567
|
-
y: (touchList[0].y + touchList[1].y) / 2
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
private triggerZoomComplete(map: Maps, prevLevel: number, type: string): void {
|
|
572
|
-
if (map.zoomSettings.enable) {
|
|
573
|
-
let zoomArgs: IMapZoomEventArgs;
|
|
574
|
-
if (map.isTileMap) {
|
|
575
|
-
map.mapScaleValue = isNullOrUndefined(map.mapScaleValue) ? 1 : map.mapScaleValue;
|
|
576
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - (0.01 * map.mapScaleValue)) / map.scale;
|
|
577
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - (0.01 * map.mapScaleValue)) / map.scale;
|
|
578
|
-
}
|
|
579
|
-
const minMaxLatitudeLongitude : IMinMaxLatitudeLongitude = this.maps.getMinMaxLatitudeLongitude();
|
|
580
|
-
if (!map.isTileMap) {
|
|
581
|
-
zoomArgs = {
|
|
582
|
-
cancel: false, name: 'zoomComplete', type: type, maps: map,
|
|
583
|
-
tileTranslatePoint: {}, translatePoint: { previous: map.previousPoint, current: map.translatePoint },
|
|
584
|
-
tileZoomLevel: {}, scale: { previous: map.previousScale, current: map.scale },
|
|
585
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
586
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
587
|
-
};
|
|
588
|
-
} else {
|
|
589
|
-
zoomArgs = {
|
|
590
|
-
cancel: false, name: 'zoomComplete', type: type, maps: map,
|
|
591
|
-
tileTranslatePoint: { previous: map.tileTranslatePoint, current: map.tileTranslatePoint }, translatePoint: { previous: map.previousPoint, current: map.translatePoint },
|
|
592
|
-
tileZoomLevel: { previous: prevLevel, current: map.tileZoomLevel }, scale: { previous: map.previousScale, current: map.scale },
|
|
593
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
594
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
this.maps.trigger('zoomComplete', zoomArgs);
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @returns {void}
|
|
603
|
-
* @private
|
|
604
|
-
*/
|
|
605
|
-
public drawZoomRectangle(): void {
|
|
606
|
-
const map: Maps = this.maps;
|
|
607
|
-
const down: Point = this.mouseDownPoints;
|
|
608
|
-
const move: Point = this.mouseMovePoints;
|
|
609
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
610
|
-
const border: any = { width: 1, color: this.maps.themeStyle.rectangleZoomBorderColor };
|
|
611
|
-
const width: number = Math.abs(move.x - down.x);
|
|
612
|
-
const height: number = Math.abs(move.y - down.y);
|
|
613
|
-
const x: number = ((move.x > down.x) ? down.x : down.x - width);
|
|
614
|
-
const y: number = ((move.y > down.y) ? down.y : down.y - height);
|
|
615
|
-
if ((x > map.mapAreaRect.x && x < (map.mapAreaRect.x + map.mapAreaRect.width)) &&
|
|
616
|
-
(y > map.mapAreaRect.y) && (y < map.mapAreaRect.y + map.mapAreaRect.height)) {
|
|
617
|
-
this.zoomingRect = new Rect(x, y, width, height);
|
|
618
|
-
const rectSVGObject: Element = map.renderer.createSvg({
|
|
619
|
-
id: map.element.id + '_Selection_Rect_Zooming',
|
|
620
|
-
width: map.availableSize.width,
|
|
621
|
-
height: map.availableSize.height,
|
|
622
|
-
style: 'position: absolute;'
|
|
623
|
-
});
|
|
624
|
-
(rectSVGObject as HTMLElement).style.position = 'absolute';
|
|
625
|
-
const rectOption: RectOption = new RectOption(
|
|
626
|
-
map.element.id + '_ZoomRect', this.maps.themeStyle.rectangleZoomFillColor, border, this.maps.themeStyle.rectangleZoomFillOpacity, this.zoomingRect, 0, 0, '', '3'
|
|
627
|
-
);
|
|
628
|
-
rectSVGObject.appendChild(map.renderer.drawRectangle(rectOption));
|
|
629
|
-
getElementByID(map.element.id + '_Secondary_Element').appendChild(rectSVGObject);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
/**
|
|
633
|
-
* To animate the zooming process.
|
|
634
|
-
*
|
|
635
|
-
* @param {Element} element - Specifies the element
|
|
636
|
-
* @param {boolean} animate - Specifies the boolean value
|
|
637
|
-
* @param {number} x - Specifies the x value
|
|
638
|
-
* @param {number} y - Specifies the y value
|
|
639
|
-
* @param {number} scale - Specifies the scale value
|
|
640
|
-
* @returns {void}
|
|
641
|
-
*/
|
|
642
|
-
private animateTransform(element: Element, animate: boolean, x: number, y: number, scale: number): void {
|
|
643
|
-
const duration: number = this.currentLayer.animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.currentLayer.animationDuration;
|
|
644
|
-
if (!animate || duration === 0 || this.maps.isTileMap) {
|
|
645
|
-
if (!(this.maps.isTileMap && element.id.indexOf('_Polygons_Group') > -1)) {
|
|
646
|
-
element.setAttribute('transform', 'scale(' + (scale) + ') translate( ' + x + ' ' + y + ' )');
|
|
647
|
-
}
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
if (!this.maps.isTileMap) {
|
|
651
|
-
zoomAnimate(element, 0, duration, new MapLocation(x, y), scale, this.maps.mapAreaRect, this.maps);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* @param {Maps} maps - Specifies the Map control
|
|
657
|
-
* @param {boolean} isMouseWheel - Indicates whether the zoom operation was triggered by the mouse wheel.
|
|
658
|
-
* @param {boolean} animate - Specifies the animation is available or not
|
|
659
|
-
* @param {boolean} isPanning - Specifies that it is panning or not
|
|
660
|
-
* @returns {void}
|
|
661
|
-
* @private
|
|
662
|
-
*/
|
|
663
|
-
public applyTransform(maps: Maps, isMouseWheel?: boolean, animate?: boolean, isPanning?: boolean): void {
|
|
664
|
-
let layerIndex: number;
|
|
665
|
-
this.templateCount = 0;
|
|
666
|
-
let markerStyle: string;
|
|
667
|
-
const scale: number = maps.scale;
|
|
668
|
-
const x: number = maps.translatePoint.x;
|
|
669
|
-
const y: number = maps.translatePoint.y;
|
|
670
|
-
let currentLabelIndex: number = 0;
|
|
671
|
-
maps.zoomShapeCollection = [];
|
|
672
|
-
this.isPanningInProgress = isPanning || false;
|
|
673
|
-
if (document.getElementById(maps.element.id + '_mapsTooltip')) {
|
|
674
|
-
removeElement(maps.element.id + '_mapsTooltip');
|
|
675
|
-
}
|
|
676
|
-
if (maps.isTileMap) {
|
|
677
|
-
const element: HTMLElement = document.getElementById(maps.element.id + '_svg');
|
|
678
|
-
if (element) {
|
|
679
|
-
for (let k: number = 0; k < maps.layers.length; k++) {
|
|
680
|
-
const layerElement: Element = element.querySelector('#' + maps.element.id + '_LayerIndex_' + k);
|
|
681
|
-
if (layerElement) {
|
|
682
|
-
element.removeChild(layerElement);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
if (this.layerCollectionEle) {
|
|
688
|
-
for (let i: number = 0; i < this.layerCollectionEle.childElementCount; i++) {
|
|
689
|
-
const layerElement: Element = this.layerCollectionEle.childNodes[i as number] as Element;
|
|
690
|
-
if (layerElement.tagName === 'g') {
|
|
691
|
-
this.templateCount++;
|
|
692
|
-
this.index = layerElement.id.indexOf('_LayerIndex_') > -1 && parseFloat(layerElement.id.split('_LayerIndex_')[1].split('_')[0]);
|
|
693
|
-
this.currentLayer = <LayerSettings>maps.layersCollection[this.index];
|
|
694
|
-
const factor: number = maps.mapLayerPanel.calculateFactor(this.currentLayer);
|
|
695
|
-
const elementCount: number = layerElement.childElementCount;
|
|
696
|
-
const templateElement: Element = document.getElementById(maps.element.id + '_LayerIndex_' + this.index + '_Markers_Template_Group');
|
|
697
|
-
for (let j: number = 0; j < elementCount; j++) {
|
|
698
|
-
let currentEle: Element = layerElement.childNodes[j as number] as Element;
|
|
699
|
-
if (!(currentEle.id.indexOf('_Markers_Group') > -1) && (!(currentEle.id.indexOf('_bubble_Group') > -1))
|
|
700
|
-
&& (!(currentEle.id.indexOf('_dataLableIndex_Group') > -1))
|
|
701
|
-
) {
|
|
702
|
-
if (maps.isTileMap && (currentEle.id.indexOf('_line_Group') > -1)) {
|
|
703
|
-
currentEle.remove();
|
|
704
|
-
if (layerElement.children.length > 0 && layerElement.children[0]) {
|
|
705
|
-
layerElement.insertBefore(
|
|
706
|
-
maps.navigationLineModule.renderNavigation(
|
|
707
|
-
this.currentLayer, this.isPinchZooming ? this.pinchZoomScale : maps.tileZoomLevel,
|
|
708
|
-
this.index
|
|
709
|
-
),
|
|
710
|
-
layerElement.children[1]
|
|
711
|
-
);
|
|
712
|
-
} else {
|
|
713
|
-
layerElement.appendChild(maps.navigationLineModule.renderNavigation(this.currentLayer, this.isPinchZooming ? this.pinchZoomScale : maps.tileZoomLevel, this.index));
|
|
714
|
-
}
|
|
715
|
-
} else if (maps.isTileMap && (currentEle.id.indexOf('_Polygons_Group') > -1)){
|
|
716
|
-
if (this.currentLayer.polygonSettings.polygons.length > 0) {
|
|
717
|
-
this.currentLayer.polygonSettings.polygons.map((polygonSettings: PolygonSettingModel, polygonIndex: number) => {
|
|
718
|
-
const markerData: Coordinate[] = polygonSettings.points;
|
|
719
|
-
const path: string = calculatePolygonPath(maps, this.isPinchZooming ? this.pinchZoomScale : maps.tileZoomLevel, this.currentLayer, markerData);
|
|
720
|
-
const element: Element = document.getElementById(maps.element.id + '_LayerIndex_' + this.index + '_PolygonIndex_' + polygonIndex);
|
|
721
|
-
if (!isNullOrUndefined(element)) {
|
|
722
|
-
element.setAttribute('d', path);
|
|
723
|
-
}
|
|
724
|
-
});
|
|
725
|
-
document.getElementById(maps.element.id + '_LayerIndex_' + this.index + '_Polygons_Group').style.visibility = '';
|
|
726
|
-
}
|
|
727
|
-
} else if (currentEle.id.indexOf('Legend') === -1) {
|
|
728
|
-
changeBorderWidth(currentEle, this.index, scale, maps);
|
|
729
|
-
maps.zoomTranslatePoint = maps.translatePoint;
|
|
730
|
-
this.animateTransform(currentEle, animate, x, y, scale);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
} else if (currentEle.id.indexOf('_Markers_Group') > -1) {
|
|
734
|
-
if ((!this.isPanModeEnabled || !isPanning) && (!isNullOrUndefined(currentEle.childNodes[0]) || !isNullOrUndefined(templateElement.childNodes[0]))) {
|
|
735
|
-
const processElement: Element = <Element>(!isNullOrUndefined(currentEle.childNodes[0]) ? currentEle.childNodes[0] : templateElement.childNodes[0]);
|
|
736
|
-
this.markerTranslates(processElement, factor, x, y, scale, 'Marker', layerElement);
|
|
737
|
-
}
|
|
738
|
-
currentEle = layerElement.childNodes[j as number] as Element;
|
|
739
|
-
if (!isNullOrUndefined(currentEle) && currentEle.id.indexOf('Markers') !== -1) {
|
|
740
|
-
Array.prototype.forEach.call(currentEle.childNodes, (childNode: HTMLElement, k: number) => {
|
|
741
|
-
this.markerTranslate(<Element>childNode, factor, x, y, scale, 'Marker', animate);
|
|
742
|
-
const dataIndex : number = parseInt(childNode['id'].split('_dataIndex_')[1].split('_')[0], 10);
|
|
743
|
-
const markerIndex : number = parseInt(childNode['id'].split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
744
|
-
if (this.currentLayer.markerSettings[markerIndex as number].initialMarkerSelection.length > 0) {
|
|
745
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
746
|
-
const markerSelectionValues: any = this.currentLayer.markerSettings[markerIndex as number].dataSource[dataIndex as number];
|
|
747
|
-
for (let x: number = 0; x < this.currentLayer.markerSettings[markerIndex as number].initialMarkerSelection.length; x++) {
|
|
748
|
-
if (this.currentLayer.markerSettings[markerIndex as number].initialMarkerSelection[x as number]['latitude'] ===
|
|
749
|
-
markerSelectionValues['latitude'] ||
|
|
750
|
-
this.currentLayer.markerSettings[markerIndex as number].initialMarkerSelection[x as number]['longitude'] ===
|
|
751
|
-
markerSelectionValues['longitude']) {
|
|
752
|
-
maps.markerSelection(this.currentLayer.markerSettings[markerIndex as number].selectionSettings,
|
|
753
|
-
maps, currentEle.children[k as number],
|
|
754
|
-
this.currentLayer.markerSettings[markerIndex as number].dataSource[dataIndex as number]
|
|
755
|
-
);
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
if (((this.currentLayer.animationDuration > 0 || animationMode === 'Enable') || ((maps.layersCollection[0].animationDuration > 0 || animationMode === 'Enable') && this.currentLayer.type === 'SubLayer')) && !this.isPanModeEnabled) {
|
|
760
|
-
if (!maps.isTileMap) {
|
|
761
|
-
markerStyle = isMouseWheel ? markerStyle : 'visibility:hidden';
|
|
762
|
-
if (!isNullOrUndefined(markerStyle)) {
|
|
763
|
-
(currentEle as HTMLElement).style.cssText = markerStyle;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
if (this.isPanModeEnabled && maps.markerModule.sameMarkerData.length > 0) {
|
|
769
|
-
clusterSeparate(maps.markerModule.sameMarkerData, maps, currentEle, true);
|
|
770
|
-
} else if (maps.markerModule.sameMarkerData.length > 0) {
|
|
771
|
-
maps.markerModule.sameMarkerData = [];
|
|
772
|
-
if (document.getElementById(maps.element.id + '_mapsTooltip')) {
|
|
773
|
-
removeElement(maps.element.id + '_mapsTooltip');
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
if (document.getElementById(maps.element.id + '_mapsTooltip') && maps.mapsTooltipModule.tooltipTargetID.indexOf('_MarkerIndex_')
|
|
777
|
-
&& !this.isPanModeEnabled) {
|
|
778
|
-
const mapsTooltip: MapsTooltip = maps.mapsTooltipModule;
|
|
779
|
-
const tooltipElement: Element = currentEle.querySelector('#' + mapsTooltip.tooltipTargetID);
|
|
780
|
-
if (!isNullOrUndefined(tooltipElement)) {
|
|
781
|
-
if (tooltipElement['style']['visibility'] === 'hidden') {
|
|
782
|
-
removeElement(maps.element.id + '_mapsTooltip');
|
|
783
|
-
} else {
|
|
784
|
-
let x: number = parseFloat(tooltipElement.getAttribute('transform').split('(')[1].split(')')[0].split(' ')[1]);
|
|
785
|
-
let y: number = parseFloat(tooltipElement.getAttribute('transform').split('(')[1].split(')')[0].split(' ')[2]);
|
|
786
|
-
if (maps.isTileMap) {
|
|
787
|
-
x += +getElement(maps.element.id + '_tile_parent')['style']['left'].split('px')[0];
|
|
788
|
-
y += +getElement(maps.element.id + '_tile_parent')['style']['top'].split('px')[0];
|
|
789
|
-
}
|
|
790
|
-
mapsTooltip.svgTooltip.location.x = x;
|
|
791
|
-
mapsTooltip.svgTooltip.location.y = y;
|
|
792
|
-
mapsTooltip.svgTooltip.enableAnimation = false;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
} else if (currentEle.id.indexOf('_bubble_Group') > -1) {
|
|
798
|
-
let childElement: HTMLElement;
|
|
799
|
-
for (let k: number = 0; k < currentEle.childElementCount; k++) {
|
|
800
|
-
childElement = currentEle.childNodes[k as number] as HTMLElement;
|
|
801
|
-
layerIndex = parseFloat(childElement.id.split('_LayerIndex_')[1].split('_')[0]);
|
|
802
|
-
const bubleIndex: number = parseFloat(childElement.id.split('_BubbleIndex_')[1].split('_')[0]);
|
|
803
|
-
const dataIndex: number = parseFloat(childElement.id.split('_BubbleIndex_')[1].split('_')[2]);
|
|
804
|
-
for (let l: number = 0; l < maps.bubbleModule.bubbleCollection.length; l++) {
|
|
805
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
806
|
-
const bubbleCollection: any = maps.bubbleModule.bubbleCollection[l as number];
|
|
807
|
-
if (bubbleCollection['LayerIndex'] === layerIndex && bubbleCollection['BubbleIndex'] === bubleIndex &&
|
|
808
|
-
bubbleCollection['DataIndex'] === dataIndex) {
|
|
809
|
-
const centerX: number = bubbleCollection['center']['x'];
|
|
810
|
-
const centerY: number = bubbleCollection['center']['y'];
|
|
811
|
-
const currentX: number = ((centerX + x) * scale);
|
|
812
|
-
const currentY: number = ((centerY + y) * scale);
|
|
813
|
-
const duration: number = this.currentLayer.animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.currentLayer.animationDuration;
|
|
814
|
-
if (!animate || duration === 0) {
|
|
815
|
-
childElement.setAttribute('transform', 'translate( ' + currentX + ' ' + currentY + ' )');
|
|
816
|
-
} else {
|
|
817
|
-
smoothTranslate(childElement, 0, duration, new MapLocation(currentX, currentY));
|
|
818
|
-
}
|
|
819
|
-
break;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
} else if (currentEle.id.indexOf('_dataLableIndex_Group') > -1 && !isNullOrUndefined(maps.layers[this.index])) {
|
|
824
|
-
maps.zoomLabelPositions = [];
|
|
825
|
-
maps.zoomLabelPositions = maps.dataLabelModule.dataLabelCollections;
|
|
826
|
-
const labelAnimate: boolean = !maps.isTileMap && animate;
|
|
827
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
828
|
-
const intersect: any[] = [];
|
|
829
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
830
|
-
Array.prototype.forEach.call(currentEle.childNodes, (childNode: any, k: number) => {
|
|
831
|
-
if (currentEle.childNodes[k as number]['id'].indexOf('_LabelIndex_') > -1) {
|
|
832
|
-
const labelIndex: number = parseFloat(currentEle.childNodes[k as number]['id'].split('_LabelIndex_')[1].split('_')[0]);
|
|
833
|
-
const zoomShapeWidth : string = (currentEle.childNodes[k as number] as Element).id;
|
|
834
|
-
maps.zoomShapeCollection.push(zoomShapeWidth);
|
|
835
|
-
this.dataLabelTranslate(<Element>currentEle.childNodes[k as number], factor, x, y, scale, 'DataLabel', labelAnimate, currentLabelIndex, isPanning, intersect);
|
|
836
|
-
currentLabelIndex++;
|
|
837
|
-
const dataLabel: DataLabelSettingsModel = maps.layers[this.index].dataLabelSettings;
|
|
838
|
-
const border: BorderModel = dataLabel.border;
|
|
839
|
-
if (k > 0 && border['width'] > 1) {
|
|
840
|
-
if (currentEle.childNodes[k - 1]['id'].indexOf('_rectIndex_') > -1 && !isNullOrUndefined(maps.zoomLabelPositions[labelIndex as number])) {
|
|
841
|
-
const labelX: number = ((maps.zoomLabelPositions[labelIndex as number]['location']['x'] + x) * scale);
|
|
842
|
-
const labelY: number = ((maps.zoomLabelPositions[labelIndex as number]['location']['y'] + y) * scale);
|
|
843
|
-
const zoomtext: string = currentEle.childNodes[k as number]['textContent'];
|
|
844
|
-
const style: FontModel = maps.layers[this.index].dataLabelSettings.textStyle;
|
|
845
|
-
const zoomtextSize: Size = measureText(zoomtext, style);
|
|
846
|
-
const padding: number = 5;
|
|
847
|
-
const rectElement: ChildNode = currentEle.childNodes[k - 1];
|
|
848
|
-
const rectX: number = labelX - zoomtextSize['width'] / 2;
|
|
849
|
-
const rectY: number = labelY - zoomtextSize['height'] / 2 - padding;
|
|
850
|
-
rectElement['setAttribute']('x', rectX);
|
|
851
|
-
rectElement['setAttribute']('y', rectY);
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
maps.arrangeTemplate();
|
|
860
|
-
}
|
|
861
|
-
if (!isNullOrUndefined(this.currentLayer)) {
|
|
862
|
-
if (!animate || this.currentLayer.animationDuration === 0 || maps.isTileMap) {
|
|
863
|
-
this.processTemplate(x, y, scale, maps);
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
private markerTranslates(
|
|
870
|
-
element: Element | HTMLElement, factor: number, x: number, y: number, scale: number, type: string, layerElement: Element): void {
|
|
871
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
872
|
-
let templateFn: any;
|
|
873
|
-
let nullCount: number = 0;
|
|
874
|
-
let markerCounts: number = 0;
|
|
875
|
-
let markerTemplateCounts : number = 0;
|
|
876
|
-
const layerIndex: number = parseInt((element ? element : layerElement).id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
877
|
-
const markerSVGObject: Element = this.maps.renderer.createGroup({
|
|
878
|
-
id: this.maps.element.id + '_Markers_Group',
|
|
879
|
-
class: 'GroupElement'
|
|
880
|
-
});
|
|
881
|
-
(markerSVGObject as HTMLElement).style.pointerEvents = 'auto';
|
|
882
|
-
if (document.getElementById(markerSVGObject.id)) {
|
|
883
|
-
removeElement(markerSVGObject.id);
|
|
884
|
-
}
|
|
885
|
-
const mapsAreaRect: Rect = this.maps.mapAreaRect;
|
|
886
|
-
const markerTemplateElements: HTMLElement = createElement('div', {
|
|
887
|
-
id: this.maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group',
|
|
888
|
-
className: 'template'
|
|
889
|
-
});
|
|
890
|
-
markerTemplateElements.style.cssText = 'overflow: hidden; position: absolute;pointer-events: none;' +
|
|
891
|
-
'top:' + mapsAreaRect.y + 'px;' +
|
|
892
|
-
'left:' + mapsAreaRect.x + 'px;' +
|
|
893
|
-
'height:' + mapsAreaRect.height + 'px;' +
|
|
894
|
-
'width:' + mapsAreaRect.width + 'px;';
|
|
895
|
-
if (document.getElementById(markerTemplateElements.id)) {
|
|
896
|
-
removeElement(markerTemplateElements.id);
|
|
897
|
-
}
|
|
898
|
-
const currentLayers: LayerSettings = <LayerSettings>this.maps.layersCollection[layerIndex as number];
|
|
899
|
-
const allowInnerClusterSetting: boolean = this.maps.markerModule.allowInnerClusterSetting(currentLayers);
|
|
900
|
-
Array.prototype.forEach.call(currentLayers.markerSettings, (markerSettings: MarkerSettings, markerIndex: number) => {
|
|
901
|
-
markerTemplateCounts = 0;
|
|
902
|
-
markerCounts = 0;
|
|
903
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
904
|
-
const markerDatas: any[] = <any[]>markerSettings.dataSource;
|
|
905
|
-
if (!isNullOrUndefined(markerDatas)) {
|
|
906
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
907
|
-
Array.prototype.forEach.call(markerDatas, (data: any, dataIndex: number) => {
|
|
908
|
-
this.maps.markerNullCount = markerIndex >= 0 && dataIndex === 0 ? 0 : this.maps.markerNullCount;
|
|
909
|
-
let eventArgs: IMarkerRenderingEventArgs = {
|
|
910
|
-
template: markerSettings.template, data: data, maps: this.maps, marker: markerSettings,
|
|
911
|
-
cancel: false, name: markerRendering, fill: markerSettings.fill, colorValuePath: markerSettings.colorValuePath,
|
|
912
|
-
shapeValuePath: markerSettings.shapeValuePath,
|
|
913
|
-
height: !isNullOrUndefined(markerSettings.heightValuePath) && !isNullOrUndefined(data[markerSettings.heightValuePath])
|
|
914
|
-
? data[markerSettings.heightValuePath] : markerSettings.height,
|
|
915
|
-
width: !isNullOrUndefined(markerSettings.widthValuePath) && !isNullOrUndefined(data[markerSettings.widthValuePath])
|
|
916
|
-
? data[markerSettings.widthValuePath] : markerSettings.width,
|
|
917
|
-
imageUrl: markerSettings.imageUrl, imageUrlValuePath: markerSettings.imageUrlValuePath, shape: markerSettings.shape,
|
|
918
|
-
border: markerSettings.border
|
|
919
|
-
};
|
|
920
|
-
eventArgs = markerShapeChoose(eventArgs, data);
|
|
921
|
-
eventArgs = markerColorChoose(eventArgs, data);
|
|
922
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
923
|
-
this.maps.trigger('markerRendering', eventArgs, (MarkerArgs: IMarkerRenderingEventArgs) => {
|
|
924
|
-
if (markerSettings.shapeValuePath !== eventArgs.shapeValuePath ) {
|
|
925
|
-
eventArgs = markerShapeChoose(eventArgs, data);
|
|
926
|
-
}
|
|
927
|
-
if (markerSettings.colorValuePath !== eventArgs.colorValuePath ) {
|
|
928
|
-
eventArgs = markerColorChoose(eventArgs, data);
|
|
929
|
-
}
|
|
930
|
-
const lati: number = (!isNullOrUndefined(markerSettings.latitudeValuePath)) ?
|
|
931
|
-
Number(getValueFromObject(data, markerSettings.latitudeValuePath)) : !isNullOrUndefined(data['latitude']) ?
|
|
932
|
-
parseFloat(data['latitude']) : !isNullOrUndefined(data['Latitude']) ? data['Latitude'] : null;
|
|
933
|
-
const long: number = (!isNullOrUndefined(markerSettings.longitudeValuePath)) ?
|
|
934
|
-
Number(getValueFromObject(data, markerSettings.longitudeValuePath)) : !isNullOrUndefined(data['longitude']) ?
|
|
935
|
-
parseFloat(data['longitude']) : !isNullOrUndefined(data['Longitude']) ? data['Longitude'] : null;
|
|
936
|
-
const offset: Point = markerSettings.offset;
|
|
937
|
-
if (!eventArgs.cancel && markerSettings.visible && !isNullOrUndefined(long) && !isNullOrUndefined(lati)) {
|
|
938
|
-
const markerID: string = this.maps.element.id + '_LayerIndex_' + layerIndex + '_MarkerIndex_'
|
|
939
|
-
+ markerIndex + '_dataIndex_' + dataIndex;
|
|
940
|
-
const location: Point = (this.maps.isTileMap) ? convertTileLatLongToPoint(
|
|
941
|
-
new MapLocation(long, lati), this.isPinchZooming ? this.pinchZoomScale : this.maps.tileZoomLevel, this.maps.tileTranslatePoint, true
|
|
942
|
-
) : convertGeoToPoint(lati, long, factor, currentLayers, this.maps);
|
|
943
|
-
const transPoint: Point = {x: x, y: y};
|
|
944
|
-
if (eventArgs.template && (!isNaN(location.x) && !isNaN(location.y))) {
|
|
945
|
-
markerTemplateCounts++;
|
|
946
|
-
markerTemplate(eventArgs, templateFn, markerID, data, markerIndex, markerTemplateElements, location, transPoint,
|
|
947
|
-
scale, offset, this.maps);
|
|
948
|
-
} else if (!eventArgs.template && (!isNaN(location.x) && !isNaN(location.y))) {
|
|
949
|
-
markerCounts++;
|
|
950
|
-
marker(eventArgs, markerSettings, markerDatas, dataIndex, location, transPoint,
|
|
951
|
-
markerID, offset, scale, this.maps, markerSVGObject);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
nullCount += (!isNaN(lati) && !isNaN(long)) ? 0 : 1;
|
|
955
|
-
markerTemplateCounts += (eventArgs.cancel) ? 1 : 0;
|
|
956
|
-
markerCounts += (eventArgs.cancel) ? 1 : 0;
|
|
957
|
-
this.maps.markerNullCount = (isNullOrUndefined(lati) || isNullOrUndefined(long))
|
|
958
|
-
? this.maps.markerNullCount + 1 : this.maps.markerNullCount;
|
|
959
|
-
const markerDataLength: number = markerDatas.length - this.maps.markerNullCount;
|
|
960
|
-
let isMarkersClustered: boolean = false;
|
|
961
|
-
const markerGroup: NodeListOf<Element> | NodeListOf<ChildNode> = (markerSettings.clusterSettings.allowClustering
|
|
962
|
-
|| (currentLayers.markerClusterSettings.allowClustering && currentLayers.markerSettings.length > 1))
|
|
963
|
-
? markerSVGObject.querySelectorAll(`[id*='LayerIndex_${layerIndex}_MarkerIndex_${markerIndex}']:not([id*='_Group'])`)
|
|
964
|
-
: markerSVGObject.childNodes;
|
|
965
|
-
if (markerGroup.length === (markerDataLength - markerTemplateCounts - nullCount) && (type !== 'Template')) {
|
|
966
|
-
if (this.maps.isTileMap) {
|
|
967
|
-
const polygonsElement: Element = document.getElementById(this.maps.element.id + '_LayerIndex_' + layerIndex + '_Polygons_Group');
|
|
968
|
-
const polygonElement: Element = document.getElementById(this.maps.element.id + '_LayerIndex_' + layerIndex + '_Polygon_Group');
|
|
969
|
-
if (!isNullOrUndefined(polygonsElement)) {
|
|
970
|
-
polygonsElement.insertAdjacentElement('afterend', markerSVGObject);
|
|
971
|
-
} else {
|
|
972
|
-
if (!isNullOrUndefined(polygonElement)) {
|
|
973
|
-
polygonElement.insertAdjacentElement('afterend', markerSVGObject);
|
|
974
|
-
} else {
|
|
975
|
-
layerElement.insertBefore(markerSVGObject, layerElement.firstElementChild);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
} else {
|
|
979
|
-
layerElement.appendChild(markerSVGObject);
|
|
980
|
-
}
|
|
981
|
-
if (currentLayers.markerSettings[markerIndex as number].clusterSettings.allowClustering ||
|
|
982
|
-
!allowInnerClusterSetting && currentLayers.markerClusterSettings.allowClustering) {
|
|
983
|
-
this.maps.svgObject.appendChild(markerSVGObject);
|
|
984
|
-
this.maps.element.appendChild(this.maps.svgObject);
|
|
985
|
-
isMarkersClustered = clusterTemplate(currentLayers, markerSVGObject, this.maps, layerIndex, markerIndex, markerSVGObject, layerElement, true, true, null, allowInnerClusterSetting);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
const markerTemplateGroup: NodeListOf<Element> | NodeListOf<ChildNode> = (markerSettings.clusterSettings.allowClustering
|
|
989
|
-
|| (currentLayers.markerClusterSettings.allowClustering && currentLayers.markerSettings.length > 1))
|
|
990
|
-
? markerTemplateElements.querySelectorAll(`[id*='LayerIndex_${layerIndex}_MarkerIndex_${markerIndex}']:not([id*='_Group'])`)
|
|
991
|
-
: markerTemplateElements.childNodes;
|
|
992
|
-
if (markerTemplateGroup.length === (markerDataLength - markerCounts - nullCount) && getElementByID(this.maps.element.id + '_Secondary_Element')) {
|
|
993
|
-
getElementByID(this.maps.element.id + '_Secondary_Element').appendChild(markerTemplateElements);
|
|
994
|
-
if (scale >= 1) {
|
|
995
|
-
if ((markerSettings.clusterSettings.allowClustering || !allowInnerClusterSetting &&
|
|
996
|
-
currentLayers.markerClusterSettings.allowClustering) && !isMarkersClustered) {
|
|
997
|
-
clusterTemplate(currentLayers, markerTemplateElements, this.maps, layerIndex, markerIndex, markerSVGObject, layerElement, false, true, null, allowInnerClusterSetting);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
});
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* To translate the layer template elements.
|
|
1008
|
-
*
|
|
1009
|
-
* @param {number} x - Specifies the x value
|
|
1010
|
-
* @param {number} y - Specifies the y value
|
|
1011
|
-
* @param {number} scale - Specifies the scale value
|
|
1012
|
-
* @param {Maps} maps - Specifies the maps value
|
|
1013
|
-
* @returns {void}
|
|
1014
|
-
* @private
|
|
1015
|
-
*/
|
|
1016
|
-
public processTemplate(x: number, y: number, scale: number, maps: Maps): void {
|
|
1017
|
-
let currentLabelIndex: number = 0;
|
|
1018
|
-
for (let i: number = 0; i < this.templateCount; i++) {
|
|
1019
|
-
const factor: number = maps.mapLayerPanel.calculateFactor(this.currentLayer);
|
|
1020
|
-
const markerTemplateElement: HTMLElement = <HTMLElement>getElementByID(maps.element.id + '_LayerIndex_' +
|
|
1021
|
-
i + '_Markers_Template_Group');
|
|
1022
|
-
const datalabelTemplateElemement: HTMLElement = <HTMLElement>getElementByID(maps.element.id + '_LayerIndex_'
|
|
1023
|
-
+ i + '_Label_Template_Group');
|
|
1024
|
-
const polygonElement: HTMLElement = <HTMLElement>getElementByID(maps.element.id + '_LayerIndex_'
|
|
1025
|
-
+ i + '_Polygons_Group');
|
|
1026
|
-
if ((!isNullOrUndefined(markerTemplateElement)) && markerTemplateElement.childElementCount > 0) {
|
|
1027
|
-
markerTemplateElement.style.visibility = 'visible';
|
|
1028
|
-
for (let k: number = 0; k < markerTemplateElement.childElementCount; k++) {
|
|
1029
|
-
this.markerTranslate(<HTMLElement>markerTemplateElement.childNodes[k as number], factor, x, y, scale, 'Template');
|
|
1030
|
-
}
|
|
1031
|
-
}
|
|
1032
|
-
if ((!isNullOrUndefined(datalabelTemplateElemement)) && datalabelTemplateElemement.childElementCount > 0) {
|
|
1033
|
-
for (let k: number = 0; k < datalabelTemplateElemement.childElementCount; k++) {
|
|
1034
|
-
this.dataLabelTranslate(<HTMLElement>datalabelTemplateElemement.childNodes[k as number], factor, x, y, scale, 'Template', false, currentLabelIndex);
|
|
1035
|
-
currentLabelIndex++;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
if (!isNullOrUndefined(polygonElement)) {
|
|
1039
|
-
for (let k: number = 0; k < polygonElement.childElementCount; k++) {
|
|
1040
|
-
const width: number = maps.layersCollection[i as number].polygonSettings.polygons[k as number].borderWidth;
|
|
1041
|
-
(polygonElement.childNodes[k as number].childNodes[0] as HTMLElement).setAttribute('stroke-width', (width / scale).toString());
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1048
|
-
private dataLabelTranslate(element: Element | HTMLElement, factor: number, x: number, y: number, scale: number, type: string, animate: boolean = false, currentLabelIndex: number, isPanning?: boolean, intersect?: any[]): void {
|
|
1049
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1050
|
-
const labelCollection: any[] = this.maps.dataLabelModule.dataLabelCollections;
|
|
1051
|
-
let text: string; let trimmedLable: string;
|
|
1052
|
-
const style: FontModel = this.maps.layers[this.index].dataLabelSettings.textStyle;
|
|
1053
|
-
let zoomtext: string; let zoomtextSize: Size; let zoomtrimLabel: string;
|
|
1054
|
-
const layerIndex: number = parseFloat(element.id.split('_LayerIndex_')[1].split('_')[0]);
|
|
1055
|
-
const shapeIndex: number = parseFloat(element.id.split('_shapeIndex_')[1].split('_')[0]);
|
|
1056
|
-
let labelIndex: number;
|
|
1057
|
-
if (element.id.indexOf('_LabelIndex_') > -1) {
|
|
1058
|
-
labelIndex = parseFloat(element.id.split('_LabelIndex_')[1].split('_')[0]);
|
|
1059
|
-
}
|
|
1060
|
-
const duration: number = this.currentLayer.animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.currentLayer.animationDuration;
|
|
1061
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1062
|
-
const label: any = labelCollection[currentLabelIndex as number];
|
|
1063
|
-
const index: number = currentLabelIndex;
|
|
1064
|
-
if (label['layerIndex'] === layerIndex && label['shapeIndex'] === shapeIndex
|
|
1065
|
-
&& label['labelIndex'] === labelIndex) {
|
|
1066
|
-
let labelX: number = label['location']['x'];
|
|
1067
|
-
let labelY: number = label['location']['y'];
|
|
1068
|
-
if (type === 'Template') {
|
|
1069
|
-
let locationX: number = 0;
|
|
1070
|
-
let locationY: number = 0;
|
|
1071
|
-
if (this.maps.isTileMap) {
|
|
1072
|
-
zoomtext = label['dataLabelText'];
|
|
1073
|
-
zoomtextSize = measureText(zoomtext, style);
|
|
1074
|
-
locationX = ((labelX + x) * scale) - (zoomtextSize['width'] / 2);
|
|
1075
|
-
locationY = ((labelY + y) * scale) - (zoomtextSize['height']);
|
|
1076
|
-
} else {
|
|
1077
|
-
const layerEle: Element = getElementByID(this.maps.element.id + '_Layer_Collections');
|
|
1078
|
-
labelX = ((Math.abs(this.maps.baseMapRectBounds['min']['x'] - labelX)) * scale);
|
|
1079
|
-
labelY = ((Math.abs(this.maps.baseMapRectBounds['min']['y'] - labelY)) * scale);
|
|
1080
|
-
const layerOffset: ClientRect = layerEle.getBoundingClientRect();
|
|
1081
|
-
const elementOffset: ClientRect = element.parentElement.getBoundingClientRect();
|
|
1082
|
-
locationX = ((labelX) + (layerOffset.left - elementOffset.left));
|
|
1083
|
-
locationY = ((labelY) + (layerOffset.top - elementOffset.top));
|
|
1084
|
-
}
|
|
1085
|
-
(<HTMLElement>element).style.left = locationX + 'px';
|
|
1086
|
-
(<HTMLElement>element).style.top = locationY + 'px';
|
|
1087
|
-
} else {
|
|
1088
|
-
labelX = ((labelX + x) * scale); labelY = ((labelY + y) * scale);
|
|
1089
|
-
zoomtext = label['dataLabelText'];
|
|
1090
|
-
if (!animate || duration === 0) {
|
|
1091
|
-
element.setAttribute('transform', 'translate( ' + labelX + ' ' + labelY + ' )');
|
|
1092
|
-
}
|
|
1093
|
-
if ((isNullOrUndefined(isPanning) || !isPanning) && (this.maps.layers[this.index].dataLabelSettings.smartLabelMode !== 'None' ||
|
|
1094
|
-
this.maps.layers[this.index].dataLabelSettings.intersectionAction !== 'None')) {
|
|
1095
|
-
zoomtextSize = measureTextElement(zoomtext, style);
|
|
1096
|
-
const start: number = labelY - zoomtextSize['height'] / 2;
|
|
1097
|
-
const end: number = labelY + zoomtextSize['height'] / 2;
|
|
1098
|
-
const xpositionEnds: number = labelX + zoomtextSize['width'] / 2;
|
|
1099
|
-
const xpositionStart: number = labelX - zoomtextSize['width'] / 2;
|
|
1100
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1101
|
-
const textLocations: any = { rightWidth: xpositionEnds, leftWidth: xpositionStart, heightTop: start, heightBottom: end };
|
|
1102
|
-
if (this.maps.layers[this.index].dataLabelSettings.smartLabelMode === 'Hide') {
|
|
1103
|
-
if (scale > 1) {
|
|
1104
|
-
text = ((this.maps.dataLabelShape[index as number] * scale) >= zoomtextSize['width']) ? zoomtext : '';
|
|
1105
|
-
element.textContent = text;
|
|
1106
|
-
} else {
|
|
1107
|
-
text = (this.maps.dataLabelShape[index as number] >= zoomtextSize['width']) ? zoomtext : '';
|
|
1108
|
-
element.textContent = text;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
const widthList: number[] = [];
|
|
1112
|
-
if (this.maps.layers[this.index].dataLabelSettings.smartLabelMode === 'Trim') {
|
|
1113
|
-
if (scale > 1) {
|
|
1114
|
-
zoomtrimLabel = textTrim((this.maps.dataLabelShape[index as number] * scale), zoomtext, style, zoomtextSize.width, true, widthList);
|
|
1115
|
-
text = zoomtrimLabel; element.textContent = text;
|
|
1116
|
-
} else {
|
|
1117
|
-
zoomtrimLabel = textTrim(this.maps.dataLabelShape[index as number], zoomtext, style, zoomtextSize.width, true, widthList);
|
|
1118
|
-
text = zoomtrimLabel; element.textContent = text;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
if (this.maps.layers[this.index].dataLabelSettings.intersectionAction === 'Hide') {
|
|
1122
|
-
for (let m: number = 0; m < intersect.length; m++) {
|
|
1123
|
-
if (!isNullOrUndefined(intersect[m as number])) {
|
|
1124
|
-
if (textLocations['leftWidth'] > intersect[m as number]['rightWidth']
|
|
1125
|
-
|| textLocations['rightWidth'] < intersect[m as number]['leftWidth']
|
|
1126
|
-
|| textLocations['heightTop'] > intersect[m as number]['heightBottom']
|
|
1127
|
-
|| textLocations['heightBottom'] < intersect[m as number]['heightTop']) {
|
|
1128
|
-
text = !isNullOrUndefined(text) ? text : zoomtext;
|
|
1129
|
-
(element as HTMLElement).textContent = text;
|
|
1130
|
-
} else {
|
|
1131
|
-
text = ''; element.textContent = text;
|
|
1132
|
-
break;
|
|
1133
|
-
}
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
intersect.push(textLocations);
|
|
1137
|
-
}
|
|
1138
|
-
if (this.maps.layers[this.index].dataLabelSettings.intersectionAction === 'Trim') {
|
|
1139
|
-
for (let j: number = 0; j < intersect.length; j++) {
|
|
1140
|
-
if (!isNullOrUndefined(intersect[j as number])) {
|
|
1141
|
-
if (textLocations['rightWidth'] < intersect[j as number]['leftWidth']
|
|
1142
|
-
|| textLocations['leftWidth'] > intersect[j as number]['rightWidth']
|
|
1143
|
-
|| textLocations['heightBottom'] < intersect[j as number]['heightTop']
|
|
1144
|
-
|| textLocations['heightTop'] > intersect[j as number]['heightBottom']) {
|
|
1145
|
-
trimmedLable = !isNullOrUndefined(text) ? text : zoomtext;
|
|
1146
|
-
if (scale > 1) {
|
|
1147
|
-
const trimmedWidth: number = widthList.length > 0 ? widthList[0] : zoomtextSize.width;
|
|
1148
|
-
trimmedLable = textTrim((this.maps.dataLabelShape[index as number] * scale), trimmedLable, style, trimmedWidth, true);
|
|
1149
|
-
}
|
|
1150
|
-
element.textContent = trimmedLable;
|
|
1151
|
-
} else {
|
|
1152
|
-
if (textLocations['leftWidth'] > intersect[j as number]['leftWidth']) {
|
|
1153
|
-
const width: number = intersect[j as number]['rightWidth'] - textLocations['leftWidth'];
|
|
1154
|
-
const difference: number = width - (textLocations['rightWidth'] - textLocations['leftWidth']);
|
|
1155
|
-
text = !isNullOrUndefined(text) ? text : zoomtext;
|
|
1156
|
-
const trimmedWidth: number = widthList.length > 0 ? widthList[0] : zoomtextSize.width;
|
|
1157
|
-
trimmedLable = textTrim(difference, text, style, trimmedWidth, true);
|
|
1158
|
-
element.textContent = trimmedLable;
|
|
1159
|
-
break;
|
|
1160
|
-
}
|
|
1161
|
-
if (textLocations['leftWidth'] < intersect[j as number]['leftWidth']) {
|
|
1162
|
-
const width: number = textLocations['rightWidth'] - intersect[j as number]['leftWidth'];
|
|
1163
|
-
const difference: number = Math.abs(width - (textLocations['rightWidth'] - textLocations['leftWidth']));
|
|
1164
|
-
text = !isNullOrUndefined(text) ? text : zoomtext;
|
|
1165
|
-
const trimmedWidth: number = widthList.length > 0 ? widthList[0] : zoomtextSize.width;
|
|
1166
|
-
trimmedLable = textTrim(difference, text, style, trimmedWidth, true);
|
|
1167
|
-
element.textContent = trimmedLable;
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
intersect.push(textLocations);
|
|
1174
|
-
if (isNullOrUndefined(trimmedLable)) {
|
|
1175
|
-
trimmedLable = textTrim((this.maps.dataLabelShape[index as number] * scale), zoomtext, style, zoomtextSize.width, true);
|
|
1176
|
-
element.textContent = trimmedLable;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
if (animate || duration > 0) {
|
|
1181
|
-
smoothTranslate(element, 0, duration, new MapLocation(labelX, labelY));
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
*
|
|
1189
|
-
* @param {Element | HTMLElement} element - Specifies the marker element.
|
|
1190
|
-
* @param {number} factor - Specifies scale factor.
|
|
1191
|
-
* @param {number} x - Specifies the x location of the marker element.
|
|
1192
|
-
* @param {number} y - Specifies the y location of the marker element.
|
|
1193
|
-
* @param {number} scale - Specifies scale factor.
|
|
1194
|
-
* @param {number} type - Specifies the type of the marker processing.
|
|
1195
|
-
* @param {number} animate - Specifies whether the animation is enabled or not.
|
|
1196
|
-
* @returns {void}
|
|
1197
|
-
* @private
|
|
1198
|
-
*/
|
|
1199
|
-
public markerTranslate(
|
|
1200
|
-
element: Element | HTMLElement, factor: number, x: number, y: number, scale: number, type: string, animate: boolean = false
|
|
1201
|
-
): void {
|
|
1202
|
-
const layerIndex: number = parseInt(element.id.split('_LayerIndex_')[1].split('_')[0], 10);
|
|
1203
|
-
const markerIndex: number = parseInt(element.id.split('_MarkerIndex_')[1].split('_')[0], 10);
|
|
1204
|
-
const dataIndex: number = parseInt(element.id.split('_dataIndex_')[1].split('_')[0], 10);
|
|
1205
|
-
const layer: LayerSettings = <LayerSettings>this.maps.layersCollection[layerIndex as number];
|
|
1206
|
-
const marker: MarkerSettings = <MarkerSettings>layer.markerSettings[markerIndex as number];
|
|
1207
|
-
if (!isNullOrUndefined(marker) && !isNullOrUndefined(marker.dataSource) && !isNullOrUndefined(marker.dataSource[dataIndex as number])) {
|
|
1208
|
-
const lng: number = (!isNullOrUndefined(marker.longitudeValuePath)) ?
|
|
1209
|
-
Number(getValueFromObject(marker.dataSource[dataIndex as number], marker.longitudeValuePath)) :
|
|
1210
|
-
!isNullOrUndefined(marker.dataSource[dataIndex as number]['longitude']) ? parseFloat(marker.dataSource[dataIndex as number]['longitude']) :
|
|
1211
|
-
!isNullOrUndefined(marker.dataSource[dataIndex as number]['Longitude']) ? parseFloat(marker.dataSource[dataIndex as number]['Longitude']) : 0;
|
|
1212
|
-
const lat: number = (!isNullOrUndefined(marker.latitudeValuePath)) ?
|
|
1213
|
-
Number(getValueFromObject(marker.dataSource[dataIndex as number], marker.latitudeValuePath)) :
|
|
1214
|
-
!isNullOrUndefined(marker.dataSource[dataIndex as number]['latitude']) ? parseFloat(marker.dataSource[dataIndex as number]['latitude']) :
|
|
1215
|
-
!isNullOrUndefined(marker.dataSource[dataIndex as number]['Latitude']) ? parseFloat(marker.dataSource[dataIndex as number]['Latitude']) : 0;
|
|
1216
|
-
const duration: number = this.currentLayer.animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.currentLayer.animationDuration;
|
|
1217
|
-
const location: Point = (this.maps.isTileMap) ? convertTileLatLongToPoint(
|
|
1218
|
-
new Point(lng, lat), this.isPinchZooming ? this.pinchZoomScale : this.maps.tileZoomLevel, this.maps.tileTranslatePoint, true
|
|
1219
|
-
) : convertGeoToPoint(lat, lng, factor, layer, this.maps);
|
|
1220
|
-
if (this.maps.isTileMap) {
|
|
1221
|
-
if (type === 'Template') {
|
|
1222
|
-
(<HTMLElement>element).style.left = (location.x + marker.offset.x) + 'px';
|
|
1223
|
-
(<HTMLElement>element).style.top = (location.y + marker.offset.y) + 'px';
|
|
1224
|
-
} else {
|
|
1225
|
-
location.x += marker.offset.x;
|
|
1226
|
-
location.y += marker.offset.y;
|
|
1227
|
-
element.setAttribute('transform', 'translate( ' + location.x + ' ' + location.y + ' )');
|
|
1228
|
-
}
|
|
1229
|
-
} else {
|
|
1230
|
-
if (type === 'Template') {
|
|
1231
|
-
if (duration > 0) {
|
|
1232
|
-
location.x = ((Math.abs(this.maps.baseMapRectBounds['min']['x'] - location.x)) * scale);
|
|
1233
|
-
location.y = ((Math.abs(this.maps.baseMapRectBounds['min']['y'] - location.y)) * scale);
|
|
1234
|
-
const layerOffset: ClientRect = getElementByID(this.maps.element.id + '_Layer_Collections').getBoundingClientRect();
|
|
1235
|
-
const elementOffset: ClientRect = element.parentElement.getBoundingClientRect();
|
|
1236
|
-
(<HTMLElement>element).style.left = (((location.x) + (layerOffset.left - elementOffset.left)) + marker.offset.x) + 'px';
|
|
1237
|
-
(<HTMLElement>element).style.top = (((location.y) + (layerOffset.top - elementOffset.top)) + marker.offset.y) + 'px';
|
|
1238
|
-
(<HTMLElement>element).style.transform = 'translate(-50%, -50%)';
|
|
1239
|
-
} else {
|
|
1240
|
-
(<HTMLElement>element).style.left = ((location.x + x) * scale) + marker.offset.x - this.maps.mapAreaRect.x + 'px';
|
|
1241
|
-
(<HTMLElement>element).style.top = ((location.y + y) * scale) + marker.offset.y - this.maps.mapAreaRect.y + 'px';
|
|
1242
|
-
}
|
|
1243
|
-
} else {
|
|
1244
|
-
location.x = (((location.x + x) * scale) + marker.offset.x);
|
|
1245
|
-
location.y = (((location.y + y) * scale) + marker.offset.y);
|
|
1246
|
-
if (!animate || duration === 0) {
|
|
1247
|
-
element.setAttribute('transform', 'translate( ' + location.x + ' ' + location.y + ' )');
|
|
1248
|
-
} else {
|
|
1249
|
-
smoothTranslate(element, 0, duration, location);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
private markerLineAnimation(map: Maps): void {
|
|
1256
|
-
if (map.isTileMap) {
|
|
1257
|
-
for (let i: number = 0; i < map.layersCollection.length; i++) {
|
|
1258
|
-
const markerTemplateElement: HTMLElement = <HTMLElement>getElementByID(this.maps.element.id + '_LayerIndex_' + i + '_Markers_Template_Group');
|
|
1259
|
-
const lineElement: HTMLElement = <HTMLElement>getElementByID(this.maps.element.id + '_LayerIndex_' + i + '_line_Group');
|
|
1260
|
-
const polygonElement: HTMLElement = <HTMLElement>getElementByID(this.maps.element.id + '_LayerIndex_' + i + '_Polygons_Group');
|
|
1261
|
-
if (!isNullOrUndefined(markerTemplateElement)) {
|
|
1262
|
-
markerTemplateElement.style.visibility = 'hidden';
|
|
1263
|
-
}
|
|
1264
|
-
if (!isNullOrUndefined(lineElement)) {
|
|
1265
|
-
lineElement.style.visibility = 'hidden';
|
|
1266
|
-
}
|
|
1267
|
-
if (!isNullOrUndefined(polygonElement)) {
|
|
1268
|
-
polygonElement.style.visibility = 'hidden';
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
/**
|
|
1274
|
-
* @param {PanDirection} direction - Specifies the direction of the panning.
|
|
1275
|
-
* @param {number} xDifference - Specifies the distance moved in the horizontal direction.
|
|
1276
|
-
* @param {number} yDifference - Specifies the distance moved in the vertical direction.
|
|
1277
|
-
* @param {PointerEvent | TouchEvent | KeyboardEvent} event - Specifies the pointer event argument.
|
|
1278
|
-
* @returns {void}
|
|
1279
|
-
* @private
|
|
1280
|
-
*/
|
|
1281
|
-
public panning(direction: PanDirection, xDifference: number, yDifference: number, event?: PointerEvent | TouchEvent | KeyboardEvent): void {
|
|
1282
|
-
const map: Maps = this.maps; let panArgs: IMapPanEventArgs;
|
|
1283
|
-
const down: Point = this.mouseDownPoints;
|
|
1284
|
-
const move: Point = this.mouseMovePoints;
|
|
1285
|
-
const scale: number = map.scale;
|
|
1286
|
-
map.markerZoomedState = false;
|
|
1287
|
-
map.zoomPersistence = map.enablePersistence;
|
|
1288
|
-
map.defaultState = false;
|
|
1289
|
-
map.initialCheck = false;
|
|
1290
|
-
const translatePoint: Point = map.translatePoint;
|
|
1291
|
-
const prevTilePoint: Point = map.tileTranslatePoint;
|
|
1292
|
-
let x: number; let y: number;
|
|
1293
|
-
xDifference = !isNullOrUndefined(xDifference) ? xDifference : (down.x - move.x);
|
|
1294
|
-
yDifference = !isNullOrUndefined(yDifference) ? yDifference : (down.y - move.y);
|
|
1295
|
-
const layerX: number = event.type.indexOf('mouse') > -1 || event.type.indexOf('key') > -1 ? event['layerX'] : (event as TouchEvent).touches[0].pageX;
|
|
1296
|
-
const layerY: number = event.type.indexOf('mouse') > -1 || event.type.indexOf('key') > -1 ? event['layerY'] : (event as TouchEvent).touches[0].pageY;
|
|
1297
|
-
this.maps.mergeCluster();
|
|
1298
|
-
if (!map.isTileMap) {
|
|
1299
|
-
const marginTop: number = getProcessedMarginValue(map.margin.top);
|
|
1300
|
-
const legendElement: HTMLElement = document.getElementById(map.element.id + '_Legend_Group');
|
|
1301
|
-
const legendHeight: number = !isNullOrUndefined(legendElement) ? legendElement.getClientRects()[0].height : 0;
|
|
1302
|
-
x = translatePoint.x - xDifference / scale;
|
|
1303
|
-
y = translatePoint.y - yDifference / scale;
|
|
1304
|
-
const layerRect: ClientRect = getElementByID(map.element.id + '_Layer_Collections').getBoundingClientRect();
|
|
1305
|
-
const elementRect: ClientRect = getElementByID(map.element.id + '_svg').getBoundingClientRect();
|
|
1306
|
-
const panningXDirection: boolean = ((xDifference < 0 ? layerRect.left <= (elementRect.left + map.mapAreaRect.x) :
|
|
1307
|
-
((layerRect.left + layerRect.width + map.mapAreaRect.x) >= (elementRect.width))));
|
|
1308
|
-
const panningYDirection: boolean = ((yDifference < 0 ? layerRect.top <= (elementRect.top + map.mapAreaRect.y) :
|
|
1309
|
-
((layerRect.top + layerRect.height + legendHeight + marginTop) >= (elementRect.top + elementRect.height))));
|
|
1310
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1311
|
-
const location: any = this.maps.getGeoLocation(this.maps.layersCollection.length - 1, layerX, layerY);
|
|
1312
|
-
const minMaxLatitudeLongitude: IMinMaxLatitudeLongitude = this.maps.getMinMaxLatitudeLongitude();
|
|
1313
|
-
panArgs = {
|
|
1314
|
-
cancel: false, name: pan, maps: map,
|
|
1315
|
-
tileTranslatePoint: {}, translatePoint: { previous: translatePoint, current: new Point(x, y) },
|
|
1316
|
-
scale: map.scale, tileZoomLevel: map.tileZoomLevel, latitude: location['latitude'], longitude: location['longitude'],
|
|
1317
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
1318
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
1319
|
-
};
|
|
1320
|
-
map.trigger(pan, panArgs);
|
|
1321
|
-
if (!panArgs.cancel) {
|
|
1322
|
-
if (panningXDirection && panningYDirection) {
|
|
1323
|
-
map.translatePoint = new Point(x, y);
|
|
1324
|
-
this.applyTransform(map, false, false, true);
|
|
1325
|
-
} else if (panningXDirection) {
|
|
1326
|
-
map.translatePoint = new Point(x, map.translatePoint.y);
|
|
1327
|
-
this.applyTransform(map, false, false, true);
|
|
1328
|
-
} else if (panningYDirection) {
|
|
1329
|
-
map.translatePoint = new Point(map.translatePoint.x, y);
|
|
1330
|
-
this.applyTransform(map, false, false, true);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
this.maps.zoomNotApplied = false;
|
|
1334
|
-
} else if (this.maps.tileZoomLevel > 1) {
|
|
1335
|
-
x = map.tileTranslatePoint.x - xDifference;
|
|
1336
|
-
y = map.tileTranslatePoint.y - yDifference;
|
|
1337
|
-
map.tileTranslatePoint.x = x;
|
|
1338
|
-
map.tileTranslatePoint.y = y;
|
|
1339
|
-
if ((map.tileTranslatePoint.y > -10 && yDifference < 0) || ((map.tileTranslatePoint.y < -((Math.pow(2, this.maps.tileZoomLevel) - 2) * 256) && yDifference > 0))) {
|
|
1340
|
-
map.tileTranslatePoint.x = x + xDifference;
|
|
1341
|
-
map.tileTranslatePoint.y = y + yDifference;
|
|
1342
|
-
}
|
|
1343
|
-
map.translatePoint.x = (map.tileTranslatePoint.x) / map.scale;
|
|
1344
|
-
map.translatePoint.y = (map.tileTranslatePoint.y) / map.scale;
|
|
1345
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1346
|
-
const location: any = this.maps.getTileGeoLocation(layerX, layerY);
|
|
1347
|
-
const minMaxLatitudeLongitude: IMinMaxLatitudeLongitude = this.maps.getMinMaxLatitudeLongitude();
|
|
1348
|
-
panArgs = {
|
|
1349
|
-
cancel: false, name: pan, maps: map,
|
|
1350
|
-
tileTranslatePoint: { previous: prevTilePoint, current: map.tileTranslatePoint },
|
|
1351
|
-
translatePoint: { previous: translatePoint, current: map.translatePoint }, scale: map.scale,
|
|
1352
|
-
tileZoomLevel: map.tileZoomLevel, latitude: location['latitude'], longitude: location['longitude'],
|
|
1353
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
1354
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
1355
|
-
};
|
|
1356
|
-
map.trigger(pan, panArgs);
|
|
1357
|
-
map.mapLayerPanel.generateTiles(map.tileZoomLevel, map.tileTranslatePoint, 'Pan');
|
|
1358
|
-
this.applyTransform(map, false, false, true);
|
|
1359
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - xDifference) / map.scale;
|
|
1360
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - yDifference) / map.scale;
|
|
1361
|
-
}
|
|
1362
|
-
map.zoomTranslatePoint = map.translatePoint;
|
|
1363
|
-
this.mouseDownPoints = this.mouseMovePoints;
|
|
1364
|
-
this.isSingleClick = false;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
* @param {number} zoomFactor - Specifies the factor for zooming
|
|
1369
|
-
* @param {string} type - Specifies the type
|
|
1370
|
-
* @returns {void}
|
|
1371
|
-
* @private
|
|
1372
|
-
*/
|
|
1373
|
-
public toolBarZooming(zoomFactor: number, type: string): void {
|
|
1374
|
-
const map: Maps = this.maps;
|
|
1375
|
-
map.initialCheck = map.isMarkerZoomCompleted = false;
|
|
1376
|
-
map.defaultState = ((type === 'Reset' && zoomFactor === 1 && !(map.zoomSettings.resetToInitial && map.applyZoomReset))
|
|
1377
|
-
|| (type === 'ZoomOut' && zoomFactor === 1));
|
|
1378
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
1379
|
-
const scale: number = map.previousScale = map.scale;
|
|
1380
|
-
map.markerZoomedState = false;
|
|
1381
|
-
map.zoomPersistence = map.enablePersistence;
|
|
1382
|
-
map.mapScaleValue = zoomFactor;
|
|
1383
|
-
const maxZoom: number = map.zoomSettings.maxZoom;
|
|
1384
|
-
const minZoom: number = map.zoomSettings.minZoom;
|
|
1385
|
-
const size: Rect = map.mapAreaRect;
|
|
1386
|
-
const translatePoint: Point = map.previousPoint = map.translatePoint;
|
|
1387
|
-
const prevTilePoint: Point = map.tileTranslatePoint;
|
|
1388
|
-
this.maps.mergeCluster();
|
|
1389
|
-
map.previousProjection = type === 'Reset' ? undefined : map.projectionType;
|
|
1390
|
-
zoomFactor = (type === 'ZoomOut') ? (Math.round(zoomFactor) === 1 ? 1 : zoomFactor) : zoomFactor;
|
|
1391
|
-
zoomFactor = (type === 'Reset') ? minZoom : (Math.round(zoomFactor) === 0) ? 1 : zoomFactor;
|
|
1392
|
-
zoomFactor = (minZoom > zoomFactor && type === 'ZoomIn') ? minZoom + 1 : zoomFactor;
|
|
1393
|
-
if ((!map.isTileMap) && (type === 'ZoomIn' ? zoomFactor >= minZoom && Math.round(zoomFactor) <= maxZoom : zoomFactor >= minZoom
|
|
1394
|
-
|| map.isReset)) {
|
|
1395
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1396
|
-
const min: any = map.baseMapRectBounds['min'] as any;
|
|
1397
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1398
|
-
const max: any = map.baseMapRectBounds['max'] as any;
|
|
1399
|
-
let mapWidth: number = Math.abs(max['x'] - min['x']);
|
|
1400
|
-
let mapHeight: number = Math.abs(min['y'] - max['y']);
|
|
1401
|
-
let translatePointX: number;
|
|
1402
|
-
let translatePointY: number;
|
|
1403
|
-
if (zoomFactor < 1.2 && map.projectionType !== 'Eckert5') {
|
|
1404
|
-
if (mapHeight === 0 || mapWidth === 0 || mapHeight === mapWidth) {
|
|
1405
|
-
mapWidth = size.width / 2;
|
|
1406
|
-
mapHeight = size.height;
|
|
1407
|
-
}
|
|
1408
|
-
zoomFactor = parseFloat(Math.min(size.width / mapWidth, size.height / mapHeight).toFixed(2));
|
|
1409
|
-
zoomFactor = zoomFactor > 1.05 ? 1 : zoomFactor;
|
|
1410
|
-
map.translatePoint = this.calculateInitalZoomTranslatePoint(zoomFactor, mapWidth, mapHeight, size, min, map);
|
|
1411
|
-
} else {
|
|
1412
|
-
translatePointX = translatePoint.x - (((size.width / scale) - (size.width / zoomFactor)) / 2);
|
|
1413
|
-
translatePointY = translatePoint.y - (((size.height / scale) - (size.height / zoomFactor)) / 2);
|
|
1414
|
-
const currentHeight: number = Math.abs(map.baseMapRectBounds['max']['y'] - map.baseMapRectBounds['min']['y']) * zoomFactor;
|
|
1415
|
-
translatePointX = (currentHeight < map.mapAreaRect.height) ? (size.x + ((-(min['x'])) + ((size.width / 2) - (mapWidth / 2))))
|
|
1416
|
-
: translatePointX;
|
|
1417
|
-
translatePointY = (currentHeight < map.mapAreaRect.height) ? (size.y + ((-(min['y'])) + ((size.height / 2) - (mapHeight / 2))))
|
|
1418
|
-
: translatePointY;
|
|
1419
|
-
map.translatePoint = new Point(translatePointX, translatePointY);
|
|
1420
|
-
}
|
|
1421
|
-
map.zoomTranslatePoint = map.translatePoint;
|
|
1422
|
-
map.scale = zoomFactor;
|
|
1423
|
-
if (this.triggerZoomEvent(prevTilePoint, prevLevel, type)) {
|
|
1424
|
-
map.translatePoint = map.zoomTranslatePoint = map.previousPoint;
|
|
1425
|
-
map.scale = map.previousScale;
|
|
1426
|
-
} else {
|
|
1427
|
-
this.applyTransform(map, false, true);
|
|
1428
|
-
}
|
|
1429
|
-
} else if ((map.isTileMap) && ((zoomFactor >= minZoom && zoomFactor <= maxZoom) || map.isReset)) {
|
|
1430
|
-
let tileZoomFactor: number = prevLevel < minZoom && !map.isReset ? minZoom : zoomFactor;
|
|
1431
|
-
map.scale = Math.pow(2, tileZoomFactor - 1);
|
|
1432
|
-
map.tileZoomLevel = tileZoomFactor;
|
|
1433
|
-
if (map.previousScale !== map.scale || map.isReset) {
|
|
1434
|
-
map.zoomSettings.zoomFactor = zoomFactor;
|
|
1435
|
-
const position: Point = { x: map.availableSize.width / 2, y: map.availableSize.height / 2 };
|
|
1436
|
-
this.getTileTranslatePosition(prevLevel, tileZoomFactor, position, type);
|
|
1437
|
-
if (map.zoomSettings.resetToInitial && map.applyZoomReset && type === 'Reset' || (type === 'ZoomOut' && map.zoomSettings.resetToInitial && map.applyZoomReset && tileZoomFactor <= map.initialZoomLevel)) {
|
|
1438
|
-
map.initialCheck = true;
|
|
1439
|
-
map.zoomPersistence = false;
|
|
1440
|
-
map.tileTranslatePoint.x = map.initialTileTranslate.x;
|
|
1441
|
-
map.tileTranslatePoint.y = map.initialTileTranslate.y;
|
|
1442
|
-
tileZoomFactor = map.tileZoomLevel = map.mapScaleValue = map.initialZoomLevel;
|
|
1443
|
-
}
|
|
1444
|
-
if (this.triggerZoomEvent(prevTilePoint, prevLevel, type)) {
|
|
1445
|
-
map.translatePoint = map.tileTranslatePoint = new Point(0, 0);
|
|
1446
|
-
map.scale = map.previousScale;
|
|
1447
|
-
map.tileZoomLevel = prevLevel;
|
|
1448
|
-
map.zoomSettings.zoomFactor = map.previousScale;
|
|
1449
|
-
} else {
|
|
1450
|
-
map.translatePoint.y = (map.tileTranslatePoint.y - (0.01 * map.mapScaleValue)) / map.scale;
|
|
1451
|
-
map.translatePoint.x = (map.tileTranslatePoint.x - (0.01 * map.mapScaleValue)) / map.scale;
|
|
1452
|
-
if (document.getElementById(this.maps.element.id + '_LayerIndex_1')) {
|
|
1453
|
-
document.getElementById(this.maps.element.id + '_LayerIndex_1').style.display = 'none';
|
|
1454
|
-
}
|
|
1455
|
-
if (document.querySelector('.GroupElement')) {
|
|
1456
|
-
(document.querySelector('.GroupElement') as HTMLElement).style.display = 'none';
|
|
1457
|
-
}
|
|
1458
|
-
this.markerLineAnimation(map);
|
|
1459
|
-
map.mapLayerPanel.generateTiles(tileZoomFactor, map.tileTranslatePoint, type);
|
|
1460
|
-
const animationDuration: number = this.maps.layersCollection[0].animationDuration === 0 && animationMode === 'Enable' ? 1000 : this.maps.layersCollection[0].animationDuration;
|
|
1461
|
-
setTimeout(() => {
|
|
1462
|
-
if (type === 'ZoomOut' || type === 'Reset') {
|
|
1463
|
-
// element1.removeChild(element1.children[element1.childElementCount - 1]);
|
|
1464
|
-
// element1.childElementCount ? element1.removeChild(element1.children[element1.childElementCount - 1]) : element1;
|
|
1465
|
-
}
|
|
1466
|
-
this.applyTransform(this.maps, false, true);
|
|
1467
|
-
if (document.getElementById(this.maps.element.id + '_LayerIndex_1')) {
|
|
1468
|
-
document.getElementById(this.maps.element.id + '_LayerIndex_1').style.display = 'block';
|
|
1469
|
-
}
|
|
1470
|
-
this.maps.isAddLayer = false;
|
|
1471
|
-
}, animationDuration);
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
this.maps.zoomNotApplied = false;
|
|
1475
|
-
}
|
|
1476
|
-
this.triggerZoomComplete(map, prevLevel, type);
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
/**
|
|
1480
|
-
* @returns {void}
|
|
1481
|
-
* @private
|
|
1482
|
-
*/
|
|
1483
|
-
public createZoomingToolbars(): void {
|
|
1484
|
-
const map: Maps = this.maps;
|
|
1485
|
-
this.toolBarGroup = map.renderer.createGroup({
|
|
1486
|
-
id: map.element.id + '_Zooming_KitCollection',
|
|
1487
|
-
opacity: map.theme.toLowerCase() === 'fluentdark' ? 0.6 : 0.3
|
|
1488
|
-
});
|
|
1489
|
-
let xSpacing: number = 15; let ySpacing: number = 15;
|
|
1490
|
-
const toolbar: ZoomToolbarSettingsModel = map.zoomSettings.toolbarSettings;
|
|
1491
|
-
const button: ZoomToolbarButtonSettingsModel = map.zoomSettings.toolbarSettings.buttonSettings;
|
|
1492
|
-
this.maps.toolbarProperties = {
|
|
1493
|
-
toolBarOrientation: toolbar.orientation,
|
|
1494
|
-
highlightColor: button.highlightColor,
|
|
1495
|
-
selectionColor: button.selectionColor,
|
|
1496
|
-
horizontalAlignment: toolbar.horizontalAlignment,
|
|
1497
|
-
verticalAlignment: toolbar.verticalAlignment,
|
|
1498
|
-
color: button.color,
|
|
1499
|
-
shapeOpacity: button.opacity,
|
|
1500
|
-
borderOpacity: button.borderOpacity
|
|
1501
|
-
};
|
|
1502
|
-
const buttonRadius: number = button.radius || map.themeStyle.zoomButtonRadius;
|
|
1503
|
-
const cx: number = buttonRadius / 4;
|
|
1504
|
-
const cy: number = buttonRadius / 4;
|
|
1505
|
-
const radius: number = buttonRadius / 2;
|
|
1506
|
-
const padding: number = button.padding;
|
|
1507
|
-
const orientation: Orientation = this.maps.toolbarProperties.toolBarOrientation;
|
|
1508
|
-
const toolbarCollection: string[] = map.zoomSettings.toolbarSettings.buttonSettings.toolbarItems.map((value: string) => { return value; });
|
|
1509
|
-
xSpacing = (buttonRadius / 4) + (button.borderWidth / 2) + padding;
|
|
1510
|
-
ySpacing = (buttonRadius / 4) + (button.borderWidth / 2) + padding;
|
|
1511
|
-
let shadowElement: string = '<filter id="chart_shadow" height="130%"><feGaussianBlur in="SourceAlpha" stdDeviation="5"/>';
|
|
1512
|
-
shadowElement += '<feOffset dx="-3" dy="4" result="offsetblur"/><feComponentTransfer><feFuncA type="linear" slope="1"/>';
|
|
1513
|
-
shadowElement += '</feComponentTransfer><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge></filter>';
|
|
1514
|
-
const toolBarLength: number = toolbarCollection.length;
|
|
1515
|
-
const toolWidth: number = (orientation === 'Horizontal') ? ((toolBarLength * buttonRadius) + (toolBarLength * padding) + padding + (toolBarLength * button.borderWidth)) : (buttonRadius + button.borderWidth + (2 * padding));
|
|
1516
|
-
const toolHeight: number = (orientation === 'Horizontal') ? (buttonRadius + button.borderWidth + (2 * padding)) : ((toolBarLength * buttonRadius) + (toolBarLength * padding) + padding + (toolBarLength * button.borderWidth));
|
|
1517
|
-
const defElement: Element = map.renderer.createDefs();
|
|
1518
|
-
defElement.innerHTML = shadowElement;
|
|
1519
|
-
this.toolBarGroup.appendChild(defElement);
|
|
1520
|
-
const outerElement: Element = map.renderer.drawRectangle(new RectOption(
|
|
1521
|
-
map.element.id + '_Zooming_Rect', toolbar.backgroundColor, { color: toolbar.borderColor, width: toolbar.borderWidth, opacity: toolbar.borderOpacity },
|
|
1522
|
-
toolbar.borderOpacity, new Rect((toolbar.borderWidth / 2), (toolbar.borderWidth / 2), (toolWidth - toolbar.borderWidth), (toolHeight - toolbar.borderWidth)), 0, 0
|
|
1523
|
-
));
|
|
1524
|
-
this.toolBarGroup.appendChild(outerElement);
|
|
1525
|
-
const scaleX: number = (buttonRadius - (button.borderWidth / 2)) / 30;
|
|
1526
|
-
for (let i: number = 0; i < toolbarCollection.length; i++) {
|
|
1527
|
-
if (i !== 0) {
|
|
1528
|
-
xSpacing = (map.toolbarProperties.toolBarOrientation === 'Horizontal') ? (xSpacing + (buttonRadius + padding) + button.borderWidth) : xSpacing;
|
|
1529
|
-
ySpacing = (map.toolbarProperties.toolBarOrientation === 'Horizontal') ? ySpacing : (ySpacing + (buttonRadius + padding) + button.borderWidth);
|
|
1530
|
-
}
|
|
1531
|
-
const toolbar: string = toolbarCollection[i as number];
|
|
1532
|
-
const pathStroke: string = !isNullOrUndefined(this.maps.toolbarProperties.color) ? this.maps.toolbarProperties.color : this.maps.themeStyle.zoomFillColor;
|
|
1533
|
-
const borderColor: string = button.borderColor || (this.maps.themeStyle.zoomBorderColor || this.maps.themeStyle.zoomFillColor);
|
|
1534
|
-
this.currentToolbarEle = map.renderer.createGroup({
|
|
1535
|
-
id: map.element.id + '_Zooming_ToolBar_' + toolbar + '_Group',
|
|
1536
|
-
transform: 'translate( ' + xSpacing + ' ' + ySpacing + ' ) '
|
|
1537
|
-
});
|
|
1538
|
-
this.currentToolbarEle.setAttribute('class', 'e-maps-toolbar');
|
|
1539
|
-
this.currentToolbarEle.appendChild(map.renderer.drawCircle(
|
|
1540
|
-
new CircleOption(map.element.id + '_Zooming_ToolBar_' + toolbar + '_Rect', button.fill, { color: borderColor, width: button.borderWidth, opacity: button.borderOpacity }, button.opacity, cx, cy, radius, '')
|
|
1541
|
-
) as SVGRectElement);
|
|
1542
|
-
const opacity: number = 1;
|
|
1543
|
-
let direction: string = '';
|
|
1544
|
-
const fill: string = button.fill;
|
|
1545
|
-
this.selectionColor = this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor;
|
|
1546
|
-
switch (toolbar.toLowerCase()) {
|
|
1547
|
-
case 'zoom': {
|
|
1548
|
-
let fillColor: string;
|
|
1549
|
-
let strokeColor: string;
|
|
1550
|
-
direction = 'M0.001,14.629L1.372,16l4.571-4.571v-0.685l0.228-0.274c1.051,0.868,2.423,1.417,3.885,1.417c3.291,0,';
|
|
1551
|
-
direction += '5.943-2.651,5.943-5.943S13.395,0,10.103,0S4.16,2.651,4.16,5.943c0,1.508,0.503,2.834,1.417,3.885l-0.274,0.228H4.571';
|
|
1552
|
-
direction = direction + 'L0.001,14.629L0.001,14.629z M5.943,5.943c0-2.285,1.828-4.114,4.114-4.114s4.114,1.828,4.114,';
|
|
1553
|
-
this.currentToolbarEle.setAttribute('class', (this.maps.zoomSettings.enableSelectionZooming ? 'e-maps-toolbar' : ''));
|
|
1554
|
-
if (this.maps.zoomSettings.enablePanning && !this.maps.zoomSettings.enableSelectionZooming) {
|
|
1555
|
-
fillColor = fill;
|
|
1556
|
-
strokeColor = pathStroke;
|
|
1557
|
-
} else if (this.maps.zoomSettings.enablePanning && this.maps.zoomSettings.enableSelectionZooming) {
|
|
1558
|
-
fillColor = fill;
|
|
1559
|
-
strokeColor = pathStroke;
|
|
1560
|
-
} else if (!this.maps.zoomSettings.enablePanning && !this.maps.zoomSettings.enableSelectionZooming) {
|
|
1561
|
-
fillColor = fill;
|
|
1562
|
-
strokeColor = pathStroke;
|
|
1563
|
-
} else if (!this.maps.zoomSettings.enablePanning && this.maps.zoomSettings.enableSelectionZooming) {
|
|
1564
|
-
fillColor = this.maps.themeStyle.zoomFillColor;
|
|
1565
|
-
strokeColor = pathStroke;
|
|
1566
|
-
} else {
|
|
1567
|
-
fillColor = this.selectionColor;
|
|
1568
|
-
strokeColor = this.selectionColor;
|
|
1569
|
-
}
|
|
1570
|
-
const zoomPath: Element = map.renderer.drawPath(new PathOption(
|
|
1571
|
-
map.element.id + '_Zooming_ToolBar_' + toolbar, fillColor, 1, strokeColor, opacity, opacity, null,
|
|
1572
|
-
direction + '4.114s-1.828,4.114-4.114,4.114S5.943,8.229,5.943,5.943z')
|
|
1573
|
-
);
|
|
1574
|
-
zoomPath.setAttribute('transform', 'scale( ' + scaleX + ',' + scaleX + ' )');
|
|
1575
|
-
this.currentToolbarEle.appendChild(zoomPath);
|
|
1576
|
-
this.zoomElements = this.currentToolbarEle;
|
|
1577
|
-
this.wireEvents(this.currentToolbarEle, this.performToolBarAction);
|
|
1578
|
-
break;
|
|
1579
|
-
}
|
|
1580
|
-
case 'zoomin':
|
|
1581
|
-
direction = 'M 8, 0 L 8, 16 M 0, 8 L 16, 8';
|
|
1582
|
-
/* eslint-disable no-case-declarations */
|
|
1583
|
-
const zoomInPath: Element = map.renderer.drawPath(new PathOption(
|
|
1584
|
-
map.element.id + '_Zooming_ToolBar_' + toolbar + '_Path', fill, 3, pathStroke, 1, 1, null, direction)
|
|
1585
|
-
);
|
|
1586
|
-
/* eslint-enable no-case-declarations */
|
|
1587
|
-
zoomInPath.setAttribute('transform', 'scale( ' + scaleX + ',' + scaleX + ' )');
|
|
1588
|
-
this.currentToolbarEle.appendChild(zoomInPath);
|
|
1589
|
-
this.wireEvents(this.currentToolbarEle, this.performToolBarAction);
|
|
1590
|
-
break;
|
|
1591
|
-
case 'zoomout':
|
|
1592
|
-
direction = 'M 0, 8 L 16, 8';
|
|
1593
|
-
/* eslint-disable no-case-declarations */
|
|
1594
|
-
const zoomOutPath: Element = map.renderer.drawPath(new PathOption(
|
|
1595
|
-
map.element.id + '_Zooming_ToolBar_' + toolbar, fill, 3, pathStroke, 1, 1, null, direction)
|
|
1596
|
-
);
|
|
1597
|
-
/* eslint-enable no-case-declarations */
|
|
1598
|
-
zoomOutPath.setAttribute('transform', 'scale( ' + scaleX + ',' + scaleX + ' )');
|
|
1599
|
-
this.currentToolbarEle.appendChild(zoomOutPath);
|
|
1600
|
-
this.wireEvents(this.currentToolbarEle, this.performToolBarAction);
|
|
1601
|
-
break;
|
|
1602
|
-
case 'pan': {
|
|
1603
|
-
let color: string;
|
|
1604
|
-
direction = 'M5,3h2.3L7.275,5.875h1.4L8.65,3H11L8,0L5,3z M3,11V8.7l2.875,0.025v-1.4L3,7.35V5L0,8L3,';
|
|
1605
|
-
direction += '11z M11,13H8.7l0.025-2.875h-1.4L7.35,13H5l3,3L11,13z M13,5v2.3l-2.875-0.025v1.4L13,8.65V11l3-3L13,5z';
|
|
1606
|
-
this.currentToolbarEle.setAttribute('class', (this.maps.zoomSettings.enablePanning ? 'e-maps-toolbar' : ''));
|
|
1607
|
-
if (this.maps.zoomSettings.enablePanning && this.maps.zoomModule.isDragZoom) {
|
|
1608
|
-
color = this.selectionColor || this.maps.themeStyle.zoomFillColor;
|
|
1609
|
-
} else if (!this.maps.zoomSettings.enablePanning) {
|
|
1610
|
-
color = this.selectionColor || this.maps.themeStyle.zoomFillColor;
|
|
1611
|
-
this.currentToolbarEle.setAttribute('class', '');
|
|
1612
|
-
}
|
|
1613
|
-
else {
|
|
1614
|
-
color = fill || this.maps.themeStyle.zoomFillColor;
|
|
1615
|
-
}
|
|
1616
|
-
const panPath: Element = map.renderer.drawPath(new PathOption(
|
|
1617
|
-
map.element.id + '_Zooming_ToolBar_' + toolbar, color, 1, pathStroke, opacity, opacity, null,
|
|
1618
|
-
direction)
|
|
1619
|
-
);
|
|
1620
|
-
panPath.setAttribute('transform', 'scale( ' + scaleX + ',' + scaleX + ' )');
|
|
1621
|
-
this.currentToolbarEle.appendChild(panPath);
|
|
1622
|
-
this.panColor = color;
|
|
1623
|
-
this.panElements = this.currentToolbarEle;
|
|
1624
|
-
this.wireEvents(this.currentToolbarEle, this.performToolBarAction);
|
|
1625
|
-
break;
|
|
1626
|
-
}
|
|
1627
|
-
case 'reset':
|
|
1628
|
-
direction = 'M12.364,8h-2.182l2.909,3.25L16,8h-2.182c0-3.575-2.618-6.5-5.818-6.5c-1.128,0-2.218,0.366-3.091,';
|
|
1629
|
-
direction += '1.016l1.055,1.178C6.581,3.328,7.272,3.125,8,3.125C10.4,3.125,12.363,5.319,12.364,8L12.364,8z M11.091,';
|
|
1630
|
-
direction += '13.484l-1.055-1.178C9.419,12.672,8.728,12.875,8,12.875c-2.4,0-4.364-2.194-4.364-4.875h2.182L2.909,4.75L0,8h2.182c0,';
|
|
1631
|
-
/* eslint-disable no-case-declarations */
|
|
1632
|
-
const resetPath: Element = map.renderer.drawPath(new PathOption(
|
|
1633
|
-
map.element.id + '_Zooming_ToolBar_' + toolbar, fill, null, pathStroke,
|
|
1634
|
-
1, 1, null, direction + '3.575,2.618,6.5,5.818,6.5C9.128,14.5,10.219,14.134,11.091,13.484L11.091,13.484z')
|
|
1635
|
-
);
|
|
1636
|
-
/* eslint-enable no-case-declarations */
|
|
1637
|
-
resetPath.setAttribute('transform', 'scale( ' + scaleX + ',' + scaleX + ' )');
|
|
1638
|
-
this.currentToolbarEle.appendChild(resetPath);
|
|
1639
|
-
this.wireEvents(this.currentToolbarEle, this.performToolBarAction);
|
|
1640
|
-
break;
|
|
1641
|
-
}
|
|
1642
|
-
this.toolBarGroup.appendChild(this.currentToolbarEle);
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
/**
|
|
1647
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
1648
|
-
* @returns {void}
|
|
1649
|
-
* @private
|
|
1650
|
-
*/
|
|
1651
|
-
public performToolBarAction(e: PointerEvent): void {
|
|
1652
|
-
const target: Element = <Element>e.target;
|
|
1653
|
-
e.stopImmediatePropagation();
|
|
1654
|
-
const isTouch: boolean = e.pointerType === 'touch' || e.pointerType === '2' || (e.type.indexOf('touch') > -1);
|
|
1655
|
-
const toolbar: string = target.id.split('_Zooming_ToolBar_')[1].split('_')[0];
|
|
1656
|
-
let isToolbarPerform: boolean = true;
|
|
1657
|
-
switch (toolbar.toLowerCase()) {
|
|
1658
|
-
case 'zoomin':
|
|
1659
|
-
isToolbarPerform = (this.maps.isTileMap ? this.maps.tileZoomLevel : this.maps.scale) + 1 <= this.maps.zoomSettings.maxZoom;
|
|
1660
|
-
break;
|
|
1661
|
-
case 'zoomout':
|
|
1662
|
-
/* eslint-disable no-case-declarations */
|
|
1663
|
-
const scaleValue: number = this.maps.isTileMap ? this.maps.tileZoomLevel : this.maps.scale;
|
|
1664
|
-
/* eslint-enable no-case-declarations */
|
|
1665
|
-
isToolbarPerform = (this.maps.projectionType === 'Miller' || this.maps.projectionType === 'Winkel3' ||
|
|
1666
|
-
this.maps.projectionType === 'AitOff') ? Math.round(scaleValue) - 1 >= this.maps.zoomSettings.minZoom :
|
|
1667
|
-
(scaleValue) - 1 >= this.maps.zoomSettings.minZoom;
|
|
1668
|
-
break;
|
|
1669
|
-
case 'reset' :
|
|
1670
|
-
isToolbarPerform = Math.round(this.maps.isTileMap ? this.maps.tileZoomLevel : this.maps.scale) !== this.maps.zoomSettings.minZoom;
|
|
1671
|
-
break;
|
|
1672
|
-
}
|
|
1673
|
-
if (isTouch && isToolbarPerform) {
|
|
1674
|
-
this.handled = true;
|
|
1675
|
-
this.performZoomingByToolBar(toolbar);
|
|
1676
|
-
} else if ((e.type === 'mousedown' || e.type === 'pointerdown') && !this.handled && isToolbarPerform) {
|
|
1677
|
-
this.handled = false;
|
|
1678
|
-
this.performZoomingByToolBar(toolbar);
|
|
1679
|
-
} else {
|
|
1680
|
-
this.handled = false;
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
/**
|
|
1685
|
-
* @param {string} type - Specifies the type.
|
|
1686
|
-
* @returns {void}
|
|
1687
|
-
* @private
|
|
1688
|
-
*/
|
|
1689
|
-
public performZoomingByToolBar(type: string): void {
|
|
1690
|
-
const map: Maps = this.maps;
|
|
1691
|
-
map.isReset = false;
|
|
1692
|
-
let scale: number = 0;
|
|
1693
|
-
const stateColor: string = this.fillColor || this.maps.themeStyle.zoomFillColor;
|
|
1694
|
-
switch (type.toLowerCase()) {
|
|
1695
|
-
case 'zoom':
|
|
1696
|
-
this.panColor = stateColor;
|
|
1697
|
-
this.zoomColor = this.maps.zoomSettings.enableSelectionZooming ? this.selectionColor : stateColor;
|
|
1698
|
-
this.applySelection(this.zoomElements, this.zoomColor);
|
|
1699
|
-
this.applySelection(this.panElements, this.panColor);
|
|
1700
|
-
this.isPan = false;
|
|
1701
|
-
this.isZoomSelection = this.maps.zoomSettings.enableSelectionZooming;
|
|
1702
|
-
break;
|
|
1703
|
-
case 'pan':
|
|
1704
|
-
this.panColor = this.maps.zoomSettings.enablePanning ? this.selectionColor : stateColor;
|
|
1705
|
-
this.zoomColor = stateColor;
|
|
1706
|
-
if (!this.maps.zoomSettings.enablePanning) {
|
|
1707
|
-
this.applySelection(this.zoomElements, this.selectionColor);
|
|
1708
|
-
this.applySelection(this.panElements, this.panColor);
|
|
1709
|
-
} else {
|
|
1710
|
-
this.applySelection(this.zoomElements, (this.fillColor || stateColor));
|
|
1711
|
-
this.applySelection(this.panElements, this.panColor);
|
|
1712
|
-
}
|
|
1713
|
-
this.isPan = this.maps.zoomSettings.enablePanning;
|
|
1714
|
-
this.isZoomSelection = false;
|
|
1715
|
-
break;
|
|
1716
|
-
case 'zoomin':
|
|
1717
|
-
map.staticMapZoom = map.tileZoomLevel;
|
|
1718
|
-
if (map.staticMapZoom > 0 && map.staticMapZoom < map.zoomSettings.maxZoom) {
|
|
1719
|
-
map.staticMapZoom += 1;
|
|
1720
|
-
}
|
|
1721
|
-
if (map.isTileMap && map.tileZoomLevel >= map.zoomSettings.minZoom && map.tileZoomLevel < map.zoomSettings.maxZoom) {
|
|
1722
|
-
this.toolBarZooming(map.tileZoomLevel + 1, 'ZoomIn');
|
|
1723
|
-
} else if (!map.isTileMap) {
|
|
1724
|
-
this.toolBarZooming(map.scale + 1, 'ZoomIn');
|
|
1725
|
-
}
|
|
1726
|
-
scale = this.maps.isTileMap ? Math.round(this.maps.tileZoomLevel) : Math.round(this.maps.mapScaleValue);
|
|
1727
|
-
if (!this.isZoomSelection) {
|
|
1728
|
-
if (scale === map.zoomSettings.maxZoom || scale > 1 || (scale === 1 && this.maps.isTileMap)) {
|
|
1729
|
-
this.applySelection(this.zoomElements, stateColor);
|
|
1730
|
-
this.applySelection(this.panElements, map.zoomSettings.enablePanning ? this.selectionColor : stateColor);
|
|
1731
|
-
} else if (scale === 1 && !this.maps.isTileMap) {
|
|
1732
|
-
this.applySelection(this.zoomElements, stateColor);
|
|
1733
|
-
this.applySelection(this.panElements, stateColor);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
break;
|
|
1737
|
-
case 'zoomout':
|
|
1738
|
-
map.staticMapZoom = map.tileZoomLevel;
|
|
1739
|
-
map.markerCenterLatitude = null;
|
|
1740
|
-
map.markerCenterLongitude = null;
|
|
1741
|
-
this.toolBarZooming((map.isTileMap ? map.tileZoomLevel : map.scale) - 1, 'ZoomOut');
|
|
1742
|
-
scale = this.maps.isTileMap ? Math.round(this.maps.tileZoomLevel) : Math.round(this.maps.mapScaleValue);
|
|
1743
|
-
if (!this.isPan && this.isZoomSelection) {
|
|
1744
|
-
this.panColor = stateColor;
|
|
1745
|
-
this.zoomColor = this.selectionColor;
|
|
1746
|
-
this.applySelection(this.zoomElements, this.selectionColor);
|
|
1747
|
-
this.applySelection(this.panElements, this.panColor);
|
|
1748
|
-
} else {
|
|
1749
|
-
if (scale <= 1 && !map.isTileMap) {
|
|
1750
|
-
this.applySelection(this.panElements, stateColor);
|
|
1751
|
-
} else {
|
|
1752
|
-
this.applySelection(this.panElements, map.zoomSettings.enablePanning ? this.selectionColor : stateColor);
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
break;
|
|
1756
|
-
case 'reset':
|
|
1757
|
-
map.staticMapZoom = map.zoomSettings.enable ? map.zoomSettings.zoomFactor : 0;
|
|
1758
|
-
map.markerCenterLatitude = null;
|
|
1759
|
-
map.markerCenterLongitude = null;
|
|
1760
|
-
this.isZoomSelection = false;
|
|
1761
|
-
this.isPan = map.zoomSettings.enablePanning;
|
|
1762
|
-
this.toolBarZooming(map.zoomSettings.minZoom, 'Reset');
|
|
1763
|
-
if ((this.isPan && !this.isZoomSelection) || (!this.isPan && this.isZoomSelection)) {
|
|
1764
|
-
if (!this.maps.zoomSettings.enablePanning) {
|
|
1765
|
-
this.applySelection(this.zoomElements, this.selectionColor);
|
|
1766
|
-
this.applySelection(this.panElements, stateColor);
|
|
1767
|
-
}
|
|
1768
|
-
else {
|
|
1769
|
-
this.applySelection(this.zoomElements, stateColor);
|
|
1770
|
-
this.applySelection(this.panElements, this.selectionColor);
|
|
1771
|
-
}
|
|
1772
|
-
} else if (!this.isPan && !this.isZoomSelection) {
|
|
1773
|
-
this.applySelection(this.zoomElements, stateColor);
|
|
1774
|
-
this.applySelection(this.panElements, stateColor);
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
this.panningStyle(type.toLowerCase());
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
private panningStyle(toolbar: string): void {
|
|
1781
|
-
const svg: Element = getElementByID(this.maps.element.id + '_svg');
|
|
1782
|
-
if (toolbar === 'pan' || (this.isPanModeEnabled && toolbar !== 'reset')) {
|
|
1783
|
-
svg.setAttribute('class', 'e-maps-panning');
|
|
1784
|
-
} else {
|
|
1785
|
-
svg.setAttribute('class', '');
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
private applySelection(elements: Element, color: string): void {
|
|
1789
|
-
if (!elements) {
|
|
1790
|
-
return;
|
|
1791
|
-
}
|
|
1792
|
-
let childElement: HTMLElement;
|
|
1793
|
-
for (let i: number = 0; i < elements.childElementCount; i++) {
|
|
1794
|
-
childElement = elements.childNodes[i as number] as HTMLElement;
|
|
1795
|
-
if (childElement.tagName !== 'circle') {
|
|
1796
|
-
childElement.setAttribute('fill', (elements.id.indexOf('Pan') > -1 ? color : 'transparent'));
|
|
1797
|
-
childElement.setAttribute('stroke', color);
|
|
1798
|
-
}
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
|
|
1802
|
-
/**
|
|
1803
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
1804
|
-
* @returns {void}
|
|
1805
|
-
* @private
|
|
1806
|
-
*/
|
|
1807
|
-
public showTooltip(e: PointerEvent): void {
|
|
1808
|
-
const text: string = (<Element>e.target).id.split('_Zooming_ToolBar_')[1].split('_')[0];
|
|
1809
|
-
const tooltip: ZoomToolbarTooltipSettingsModel = this.maps.zoomSettings.toolbarSettings.tooltipSettings;
|
|
1810
|
-
const tooltipSettings: ZoomToolbarTooltipSettingsModel = {
|
|
1811
|
-
visible: tooltip.visible,
|
|
1812
|
-
fill: tooltip.fill,
|
|
1813
|
-
borderOpacity: tooltip.borderOpacity,
|
|
1814
|
-
borderWidth: tooltip.borderWidth,
|
|
1815
|
-
borderColor: tooltip.borderColor,
|
|
1816
|
-
fontColor: tooltip.fontColor,
|
|
1817
|
-
fontFamily: tooltip.fontFamily,
|
|
1818
|
-
fontStyle: tooltip.fontStyle,
|
|
1819
|
-
fontWeight: tooltip.fontWeight,
|
|
1820
|
-
fontSize: tooltip.fontSize || '10px',
|
|
1821
|
-
fontOpacity: tooltip.fontOpacity
|
|
1822
|
-
};
|
|
1823
|
-
tooltipSettings.fontFamily = this.maps.themeStyle.fontFamily;
|
|
1824
|
-
if (!this.isTouch) {
|
|
1825
|
-
createTooltip('EJ2_Map_Toolbar_Tip', this.maps.getLocalizedLabel(text), (e.pageY + 10), (e.pageX + 10), tooltipSettings);
|
|
1826
|
-
if (this.maps.isDevice) {
|
|
1827
|
-
clearTimeout(this.clearTimeout);
|
|
1828
|
-
this.clearTimeout = setTimeout(this.removeTooltip.bind(this), 2000);
|
|
1829
|
-
}
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
/**
|
|
1834
|
-
* @returns {void}
|
|
1835
|
-
* @private
|
|
1836
|
-
*/
|
|
1837
|
-
public removeTooltip(): void {
|
|
1838
|
-
if (getElementByID('EJ2_Map_Toolbar_Tip')) {
|
|
1839
|
-
remove(getElementByID('EJ2_Map_Toolbar_Tip'));
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
/**
|
|
1843
|
-
* @returns {void}
|
|
1844
|
-
* @private
|
|
1845
|
-
*/
|
|
1846
|
-
public alignToolBar(): void {
|
|
1847
|
-
const map: Maps = this.maps;
|
|
1848
|
-
const padding: number = 10;
|
|
1849
|
-
const element: HTMLElement = createElement('div', { id: map.element.id + '_ToolBar' });
|
|
1850
|
-
element.style.cssText = 'position:absolute;z-index:2';
|
|
1851
|
-
const rectSVGObject: Element = map.renderer.createSvg({
|
|
1852
|
-
id: map.element.id + '_Zooming_ToolBar', width: 10, height: 10
|
|
1853
|
-
});
|
|
1854
|
-
rectSVGObject.appendChild(this.toolBarGroup);
|
|
1855
|
-
element.appendChild(rectSVGObject);
|
|
1856
|
-
if (getElementByID(map.element.id + '_Secondary_Element')) {
|
|
1857
|
-
getElementByID(map.element.id + '_Secondary_Element').appendChild(element);
|
|
1858
|
-
}
|
|
1859
|
-
const toolBarSize: ClientRect = this.toolBarGroup.getBoundingClientRect();
|
|
1860
|
-
rectSVGObject.setAttribute('height', (toolBarSize.height + map.zoomSettings.toolbarSettings.borderWidth).toString());
|
|
1861
|
-
rectSVGObject.setAttribute('width', (toolBarSize.width + map.zoomSettings.toolbarSettings.borderWidth).toString());
|
|
1862
|
-
const size: Rect = !isNullOrUndefined(map.totalRect) ? map.totalRect : map.mapAreaRect;
|
|
1863
|
-
let x: number = 0; let y: number = 0;
|
|
1864
|
-
switch (map.toolbarProperties.verticalAlignment) {
|
|
1865
|
-
case 'Near':
|
|
1866
|
-
y = size.y;
|
|
1867
|
-
break;
|
|
1868
|
-
case 'Center':
|
|
1869
|
-
y = (size.height / 2) - (toolBarSize.height / 2);
|
|
1870
|
-
break;
|
|
1871
|
-
case 'Far':
|
|
1872
|
-
y = (size.height - toolBarSize.height) - padding;
|
|
1873
|
-
break;
|
|
1874
|
-
}
|
|
1875
|
-
switch (map.toolbarProperties.horizontalAlignment) {
|
|
1876
|
-
case 'Near':
|
|
1877
|
-
x = size.x;
|
|
1878
|
-
break;
|
|
1879
|
-
case 'Center':
|
|
1880
|
-
x = (size.width / 2) - (toolBarSize.width / 2);
|
|
1881
|
-
break;
|
|
1882
|
-
case 'Far':
|
|
1883
|
-
if (!isNullOrUndefined(map.legendModule) && map.legendSettings.position === 'Left') {
|
|
1884
|
-
x = size.width + size.x - toolBarSize.width - padding;
|
|
1885
|
-
} else {
|
|
1886
|
-
x = (size.width - toolBarSize.width) - padding;
|
|
1887
|
-
}
|
|
1888
|
-
break;
|
|
1889
|
-
}
|
|
1890
|
-
element.style.left = x + 'px';
|
|
1891
|
-
element.style.top = y + 'px';
|
|
1892
|
-
const color: string = this.maps.toolbarProperties.highlightColor || this.maps.themeStyle.zoomSelectionColor;
|
|
1893
|
-
const css: string = ' .e-maps-toolbar:hover > circle { stroke:' + color + '; } .e-maps-toolbar:hover > path { fill: ' + color + ' ; stroke: ' + color + '; }' +
|
|
1894
|
-
'.e-maps-toolbar:hover { cursor: pointer; } .e-maps-cursor-disable:hover { cursor: not-allowed; } .e-maps-panning:hover { cursor: pointer; } ' +
|
|
1895
|
-
'.e-maps-popup-close { display: block; opacity: 0; }';
|
|
1896
|
-
const style: HTMLStyleElement = document.createElement('style');
|
|
1897
|
-
style.appendChild(document.createTextNode(css));
|
|
1898
|
-
element.appendChild(style);
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
|
-
/**
|
|
1902
|
-
* @param {number} factor - Specifies the factor for toolbar
|
|
1903
|
-
* @param {string} id - Specifies the id
|
|
1904
|
-
* @returns {void}
|
|
1905
|
-
* @private
|
|
1906
|
-
*/
|
|
1907
|
-
public removeToolbarOpacity(factor: number, id: string): void {
|
|
1908
|
-
if (!isNullOrUndefined(this.maps) && this.maps.zoomModule && this.maps.zoomSettings.enable) {
|
|
1909
|
-
if (getElementByID(this.maps.element.id + '_Zooming_KitCollection') && id.indexOf(this.maps.element.id + '_Zooming_') > -1) {
|
|
1910
|
-
if (this.maps.isDevice) {
|
|
1911
|
-
getElementByID(this.maps.element.id + '_Zooming_KitCollection').setAttribute('opacity', '1');
|
|
1912
|
-
this.removeToolbarClass('', '', '', '', '');
|
|
1913
|
-
} else {
|
|
1914
|
-
this.removeToolbarClass(this.maps.zoomSettings.enableSelectionZooming ? 'e-maps-toolbar' : '', 'e-maps-toolbar', 'e-maps-toolbar',
|
|
1915
|
-
this.maps.zoomSettings.enablePanning ? 'e-maps-toolbar' : '', 'e-maps-toolbar');
|
|
1916
|
-
}
|
|
1917
|
-
const toolbarShapeOpacity: number = this.maps.toolbarProperties.shapeOpacity;
|
|
1918
|
-
const toolbarButtonOpacity: number = this.maps.toolbarProperties.borderOpacity;
|
|
1919
|
-
|
|
1920
|
-
if (this.maps.isTileMap && (factor <= 1.1 || this.maps.zoomSettings.minZoom === factor)) {
|
|
1921
|
-
if (!this.maps.isDevice) {
|
|
1922
|
-
this.removeToolbarClass(this.maps.zoomSettings.enableSelectionZooming ? 'e-maps-toolbar' : '', 'e-maps-toolbar', '',
|
|
1923
|
-
this.maps.zoomSettings.enablePanning ? 'e-maps-toolbar' : '', '');
|
|
1924
|
-
}
|
|
1925
|
-
if (this.maps.zoomSettings.enablePanning) {
|
|
1926
|
-
this.removePanColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1927
|
-
}
|
|
1928
|
-
if (this.isZoomSelection && this.maps.zoomSettings.enableSelectionZooming && !this.maps.isReset) {
|
|
1929
|
-
this.removeZoomColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1930
|
-
this.removePanColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1931
|
-
}
|
|
1932
|
-
this.removeZoomOpacity((this.maps.zoomSettings.enableSelectionZooming ? toolbarShapeOpacity : 0.3),
|
|
1933
|
-
(this.maps.zoomSettings.enableSelectionZooming ? toolbarButtonOpacity : 0.3), toolbarShapeOpacity, toolbarButtonOpacity,
|
|
1934
|
-
0.3, 0.3, (this.maps.zoomSettings.enablePanning ? toolbarShapeOpacity : 0.3),
|
|
1935
|
-
(this.maps.zoomSettings.enablePanning ? toolbarButtonOpacity : 0.3), 0.3, 0.3);
|
|
1936
|
-
|
|
1937
|
-
} else if ((factor <= 1.1 || this.maps.zoomSettings.minZoom === factor)) {
|
|
1938
|
-
if (!this.maps.isDevice) {
|
|
1939
|
-
this.removeToolbarClass(this.maps.zoomSettings.enableSelectionZooming ? 'e-maps-toolbar' : '', 'e-maps-toolbar', '', '', '');
|
|
1940
|
-
}
|
|
1941
|
-
if (!this.isZoomSelection && this.maps.zoomSettings.enablePanning) {
|
|
1942
|
-
this.removePanColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1943
|
-
}
|
|
1944
|
-
if (this.isZoomSelection && this.maps.zoomSettings.enableSelectionZooming && !this.maps.isReset) {
|
|
1945
|
-
this.removeZoomColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1946
|
-
this.removePanColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1947
|
-
}
|
|
1948
|
-
this.removeZoomOpacity((this.maps.zoomSettings.enableSelectionZooming ? toolbarShapeOpacity : 0.3),
|
|
1949
|
-
(this.maps.zoomSettings.enableSelectionZooming ? toolbarButtonOpacity : 0.3), toolbarShapeOpacity, toolbarButtonOpacity,
|
|
1950
|
-
0.3, 0.3, 0.3, 0.3, 0.3, 0.3);
|
|
1951
|
-
|
|
1952
|
-
} else if (factor < this.maps.zoomSettings.maxZoom) {
|
|
1953
|
-
if (!this.maps.isDevice) {
|
|
1954
|
-
this.removeToolbarClass(this.maps.zoomSettings.enableSelectionZooming ? 'e-maps-toolbar' : '', 'e-maps-toolbar', 'e-maps-toolbar',
|
|
1955
|
-
this.maps.zoomSettings.enablePanning ? 'e-maps-toolbar' : '', 'e-maps-toolbar');
|
|
1956
|
-
}
|
|
1957
|
-
if (!this.maps.zoomModule.isZoomFinal) {
|
|
1958
|
-
this.removeZoomOpacity((this.maps.zoomSettings.enableSelectionZooming ? toolbarShapeOpacity : 0.3),
|
|
1959
|
-
(this.maps.zoomSettings.enableSelectionZooming ? toolbarButtonOpacity : 0.3), toolbarShapeOpacity, toolbarButtonOpacity,
|
|
1960
|
-
toolbarShapeOpacity, toolbarButtonOpacity, (this.maps.zoomSettings.enablePanning ? toolbarShapeOpacity : 0.3),
|
|
1961
|
-
(this.maps.zoomSettings.enablePanning ? toolbarButtonOpacity : 0.3), toolbarShapeOpacity, toolbarButtonOpacity);
|
|
1962
|
-
} else {
|
|
1963
|
-
this.maps.zoomModule.isZoomFinal = false;
|
|
1964
|
-
}
|
|
1965
|
-
if (this.isZoomSelection && this.maps.zoomSettings.enableSelectionZooming) {
|
|
1966
|
-
this.removeZoomColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1967
|
-
if (this.maps.zoomModule.isPan && this.maps.zoomSettings.enablePanning) {
|
|
1968
|
-
this.removePanColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1969
|
-
}
|
|
1970
|
-
} else if (!this.isZoomSelection && this.maps.zoomSettings.enablePanning) {
|
|
1971
|
-
this.removePanColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1972
|
-
if (this.maps.zoomSettings.enableSelectionZooming) {
|
|
1973
|
-
this.removeZoomColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1974
|
-
}
|
|
1975
|
-
}
|
|
1976
|
-
} else {
|
|
1977
|
-
if (!this.maps.isDevice) {
|
|
1978
|
-
this.removeToolbarClass('', '', 'e-maps-toolbar', this.maps.zoomSettings.enablePanning ? 'e-maps-toolbar' : '', 'e-maps-toolbar');
|
|
1979
|
-
}
|
|
1980
|
-
this.removeZoomOpacity(0.3, 0.3, 0.3, 0.3, toolbarShapeOpacity, toolbarButtonOpacity,
|
|
1981
|
-
(this.maps.zoomSettings.enablePanning ? toolbarShapeOpacity : 0.3), (this.maps.zoomSettings.enablePanning ? toolbarButtonOpacity : 0.3),
|
|
1982
|
-
toolbarShapeOpacity, toolbarButtonOpacity);
|
|
1983
|
-
if (this.maps.zoomSettings.enableSelectionZooming) {
|
|
1984
|
-
this.removeZoomColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1985
|
-
}
|
|
1986
|
-
if (!this.isZoomSelection && this.maps.zoomSettings.enablePanning) {
|
|
1987
|
-
this.removePanColor(this.maps.toolbarProperties.selectionColor || this.maps.themeStyle.zoomSelectionColor);
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
else {
|
|
1992
|
-
if (!this.maps.isDevice) {
|
|
1993
|
-
this.removePanColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1994
|
-
this.removeZoomColor(this.maps.toolbarProperties.color || this.maps.themeStyle.zoomFillColor);
|
|
1995
|
-
this.removeZoomOpacity(1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
private setOpacity(circleId: string, pathId: string, circleOpacity: number, pathOpacity: number): void {
|
|
2001
|
-
if (getElementByID(this.maps.element.id + circleId)) {
|
|
2002
|
-
getElementByID(this.maps.element.id + circleId).setAttribute('stroke-opacity', circleOpacity.toString());
|
|
2003
|
-
getElementByID(this.maps.element.id + circleId).setAttribute('fill-opacity', circleOpacity.toString());
|
|
2004
|
-
getElementByID(this.maps.element.id + pathId).setAttribute('stroke-opacity', pathOpacity.toString());
|
|
2005
|
-
getElementByID(this.maps.element.id + pathId).setAttribute('fill-opacity', pathOpacity.toString());
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
private removeZoomOpacity(zoomOpacity: number, zoomStrokeOpacity: number, zoomInOpacity: number, zoomInStrokeOpacity: number, zoomOutOpacity: number,
|
|
2010
|
-
zoomOutStrokeOpacity: number, panOpacity: number, panStrokeOpacity: number, resetOpacity: number, resetStrokeOpacity: number): void {
|
|
2011
|
-
this.setOpacity('_Zooming_ToolBar_Zoom_Rect', '_Zooming_ToolBar_Zoom', zoomStrokeOpacity, zoomOpacity);
|
|
2012
|
-
this.setOpacity('_Zooming_ToolBar_ZoomIn_Rect', '_Zooming_ToolBar_ZoomIn_Path', zoomInStrokeOpacity, zoomInOpacity);
|
|
2013
|
-
this.setOpacity('_Zooming_ToolBar_ZoomOut_Rect', '_Zooming_ToolBar_ZoomOut', zoomOutStrokeOpacity, zoomOutOpacity);
|
|
2014
|
-
this.setOpacity('_Zooming_ToolBar_Pan_Rect', '_Zooming_ToolBar_Pan', panStrokeOpacity, panOpacity);
|
|
2015
|
-
this.setOpacity('_Zooming_ToolBar_Reset_Rect', '_Zooming_ToolBar_Reset', resetStrokeOpacity, resetOpacity);
|
|
2016
|
-
}
|
|
2017
|
-
/**
|
|
2018
|
-
* @param {string} zoomClassStyle - Specifies the style for zoom class.
|
|
2019
|
-
* @param {string} zoomInClassStyle - Specifies the style for zoom in.
|
|
2020
|
-
* @param {string} zoomOutClassStyle - Specifies the style for zoom out.
|
|
2021
|
-
* @param {string} panClassStyle - Specifies the style for pan.
|
|
2022
|
-
* @param {string} resetClassStyle - Specifies the style for reset.
|
|
2023
|
-
* @returns {void}
|
|
2024
|
-
* @private
|
|
2025
|
-
*/
|
|
2026
|
-
public removeToolbarClass(zoomClassStyle: string, zoomInClassStyle: string, zoomOutClassStyle: string,
|
|
2027
|
-
panClassStyle: string, resetClassStyle: string): void {
|
|
2028
|
-
if (getElementByID(this.maps.element.id + '_Zooming_KitCollection')) {
|
|
2029
|
-
if (document.getElementById(this.maps.element.id + '_Zooming_ToolBar_ZoomIn_Group')) {
|
|
2030
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_ZoomIn_Group').setAttribute('class', zoomInClassStyle);
|
|
2031
|
-
}
|
|
2032
|
-
if (document.getElementById(this.maps.element.id + '_Zooming_ToolBar_ZoomOut_Group')) {
|
|
2033
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_ZoomOut_Group').setAttribute('class', zoomOutClassStyle);
|
|
2034
|
-
}
|
|
2035
|
-
if (document.getElementById(this.maps.element.id + '_Zooming_ToolBar_Reset_Group')) {
|
|
2036
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Reset_Group').setAttribute('class', resetClassStyle);
|
|
2037
|
-
}
|
|
2038
|
-
if (document.getElementById(this.maps.element.id + '_Zooming_ToolBar_Zoom_Group') && this.maps.zoomSettings.enableSelectionZooming) {
|
|
2039
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Zoom_Group').setAttribute('class', zoomClassStyle);
|
|
2040
|
-
}
|
|
2041
|
-
if (document.getElementById(this.maps.element.id + '_Zooming_ToolBar_Pan_Group') && this.maps.zoomSettings.enablePanning) {
|
|
2042
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Pan_Group').setAttribute('class', panClassStyle);
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
private removePanColor(selectionColor: string): void {
|
|
2047
|
-
if (getElementByID(this.maps.element.id + '_Zooming_ToolBar_Pan_Rect') && this.maps.zoomSettings.enablePanning) {
|
|
2048
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Pan').setAttribute('fill', selectionColor);
|
|
2049
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Pan').setAttribute('stroke', selectionColor);
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
private removeZoomColor(selectionColor: string): void {
|
|
2053
|
-
if (getElementByID(this.maps.element.id + '_Zooming_ToolBar_Zoom_Rect') && this.maps.zoomSettings.enableSelectionZooming) {
|
|
2054
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Zoom').setAttribute('fill', 'transparent');
|
|
2055
|
-
getElementByID(this.maps.element.id + '_Zooming_ToolBar_Zoom').setAttribute('stroke', selectionColor);
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
/**
|
|
2060
|
-
* To bind events.
|
|
2061
|
-
*
|
|
2062
|
-
* @param {Element} element - Specifies the element.
|
|
2063
|
-
* @param {Function} process - Specifies the process.
|
|
2064
|
-
* @returns {void}
|
|
2065
|
-
* @private
|
|
2066
|
-
*/
|
|
2067
|
-
public wireEvents(element: Element, process: Function): void {
|
|
2068
|
-
EventHandler.add(element, Browser.touchStartEvent, process, this);
|
|
2069
|
-
EventHandler.add(element, 'mouseover', this.showTooltip, this);
|
|
2070
|
-
EventHandler.add(element, 'mouseout', this.removeTooltip, this);
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
/**
|
|
2074
|
-
* @param {WheelEvent} e - Specifies the wheel event in the map for zooming
|
|
2075
|
-
* @returns {void}
|
|
2076
|
-
* @private
|
|
2077
|
-
*/
|
|
2078
|
-
public mapMouseWheel(e: WheelEvent): void {
|
|
2079
|
-
if (this.maps.zoomSettings.enable && this.maps.zoomSettings.mouseWheelZoom) {
|
|
2080
|
-
const map: Maps = this.maps;
|
|
2081
|
-
map.markerZoomedState = false;
|
|
2082
|
-
map.zoomPersistence = map.enablePersistence;
|
|
2083
|
-
const position: Point = this.getMousePosition(e.pageX, e.pageY);
|
|
2084
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
2085
|
-
const prevScale: number = map.scale;
|
|
2086
|
-
const delta: number = 1;
|
|
2087
|
-
const staticMaxZoomLevel : number = map.zoomSettings.maxZoom;
|
|
2088
|
-
const value: number = (map.isTileMap) ? prevLevel : prevScale;
|
|
2089
|
-
this.maps.mergeCluster();
|
|
2090
|
-
if (((position.x > map.mapAreaRect.x) && (position.x < (map.mapAreaRect.x + map.mapAreaRect.width))) &&
|
|
2091
|
-
(position.y > map.mapAreaRect.y) && position.y < (map.mapAreaRect.y + map.mapAreaRect.height)) {
|
|
2092
|
-
e.preventDefault();
|
|
2093
|
-
const direction: string = (this.browserName === 'mozilla' && !this.isPointer) ?
|
|
2094
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2095
|
-
-(e.detail) / 3 > 0 ? 'ZoomIn' : 'ZoomOut' : ((e as any).wheelDelta / 120) > 0 ? 'ZoomIn' : 'ZoomOut';
|
|
2096
|
-
if (direction === 'ZoomIn') {
|
|
2097
|
-
map.mapScaleValue = value + delta;
|
|
2098
|
-
if (map.isTileMap) {
|
|
2099
|
-
map.staticMapZoom = map.tileZoomLevel;
|
|
2100
|
-
if (map.staticMapZoom > 0 && map.staticMapZoom < staticMaxZoomLevel) {
|
|
2101
|
-
map.staticMapZoom += 1;
|
|
2102
|
-
this.performZooming(position, (value + delta), direction, true);
|
|
2103
|
-
}
|
|
2104
|
-
} else {
|
|
2105
|
-
this.performZooming(position, (value + delta), direction, true);
|
|
2106
|
-
}
|
|
2107
|
-
} else {
|
|
2108
|
-
map.mapScaleValue = value - delta;
|
|
2109
|
-
map.isReset = (map.mapScaleValue < 1) ? true : false;
|
|
2110
|
-
map.staticMapZoom = map.tileZoomLevel;
|
|
2111
|
-
if (map.mapScaleValue === 1) {
|
|
2112
|
-
map.markerCenterLatitude = null;
|
|
2113
|
-
map.markerCenterLongitude = null;
|
|
2114
|
-
}
|
|
2115
|
-
if (map.staticMapZoom > 1 && map.staticMapZoom < staticMaxZoomLevel) {
|
|
2116
|
-
map.staticMapZoom -= 1;
|
|
2117
|
-
}
|
|
2118
|
-
this.performZooming(position, (value - delta), direction, true);
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
this.removeToolbarOpacity(map.mapScaleValue, (!this.maps.isDevice ? (!isNullOrUndefined(e.target) ? e.target['id'] :
|
|
2122
|
-
this.maps.element.id) : this.maps.element.id + '_Zooming_'));
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
/**
|
|
2127
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
2128
|
-
* @returns {void}
|
|
2129
|
-
* @private
|
|
2130
|
-
*/
|
|
2131
|
-
public doubleClick(e: PointerEvent): void {
|
|
2132
|
-
const pageX: number = e.pageX;
|
|
2133
|
-
const pageY: number = e.pageY;
|
|
2134
|
-
const tooltipElement: Element = (e.target as HTMLElement).closest('#' + this.maps.element.id + '_mapsTooltipparent_template');
|
|
2135
|
-
if (this.maps.zoomSettings.enable && this.maps.zoomSettings.doubleClickZoom
|
|
2136
|
-
&& !(e.target['id'].indexOf('_Zooming_') > -1) && isNullOrUndefined(tooltipElement)) {
|
|
2137
|
-
const position: Point = this.getMousePosition(pageX, pageY);
|
|
2138
|
-
const map: Maps = this.maps;
|
|
2139
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
2140
|
-
const prevScale: number = map.scale;
|
|
2141
|
-
map.mapScaleValue = map.mapScaleValue + 1;
|
|
2142
|
-
const value: number = (map.isTileMap) ? prevLevel : prevScale;
|
|
2143
|
-
if (((position.x > map.mapAreaRect.x) && (position.x < (map.mapAreaRect.x + map.mapAreaRect.width))) &&
|
|
2144
|
-
(position.y > map.mapAreaRect.y) && position.y < (map.mapAreaRect.y + map.mapAreaRect.height)) {
|
|
2145
|
-
this.performZooming(position, (value + 1), 'ZoomIn');
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
|
|
2150
|
-
/**
|
|
2151
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
2152
|
-
* @returns {void}
|
|
2153
|
-
* @private
|
|
2154
|
-
*/
|
|
2155
|
-
public mouseDownHandler(e: PointerEvent | TouchEvent): void {
|
|
2156
|
-
let pageX: number;
|
|
2157
|
-
let pageY: number;
|
|
2158
|
-
let target: Element;
|
|
2159
|
-
let touches: TouchList = null;
|
|
2160
|
-
this.isPinchZooming = false;
|
|
2161
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2162
|
-
const element: Element = <Element>e.target;
|
|
2163
|
-
if (e.type === 'touchstart') {
|
|
2164
|
-
this.isTouch = true;
|
|
2165
|
-
touches = (<TouchEvent & PointerEvent>e).touches;
|
|
2166
|
-
target = <Element>(<TouchEvent & PointerEvent>e).target;
|
|
2167
|
-
pageX = touches[0].pageX;
|
|
2168
|
-
pageY = touches[0].pageY;
|
|
2169
|
-
} else {
|
|
2170
|
-
pageX = (<PointerEvent>e).pageX;
|
|
2171
|
-
pageY = (<PointerEvent>e).pageY;
|
|
2172
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2173
|
-
target = <Element>e.target;
|
|
2174
|
-
}
|
|
2175
|
-
if (!this.isTouch) {
|
|
2176
|
-
e.preventDefault();
|
|
2177
|
-
}
|
|
2178
|
-
if (!this.maps.zoomSettings.enablePanning) {
|
|
2179
|
-
this.isPan = this.isPanModeEnabled = this.panColor !== this.selectionColor ? this.maps.zoomSettings.enablePanning
|
|
2180
|
-
: this.zoomColor === this.selectionColor;
|
|
2181
|
-
} else {
|
|
2182
|
-
this.isPan = this.isPanModeEnabled = !this.isZoomSelection;
|
|
2183
|
-
}
|
|
2184
|
-
this.mouseDownLatLong = { x: pageX, y: pageY };
|
|
2185
|
-
const scale: number = this.maps.isTileMap ? Math.round(this.maps.tileZoomLevel) : Math.round(this.maps.mapScaleValue);
|
|
2186
|
-
this.rectZoomingStart = ((this.isZoomSelection && scale < this.maps.zoomSettings.maxZoom) && this.maps.zoomSettings.enable);
|
|
2187
|
-
this.mouseDownPoints = this.getMousePosition(pageX, pageY);
|
|
2188
|
-
if (this.isTouch && touches !== null) {
|
|
2189
|
-
this.firstMove = true;
|
|
2190
|
-
this.pinchFactor = this.maps.scale;
|
|
2191
|
-
this.fingers = touches.length;
|
|
2192
|
-
}
|
|
2193
|
-
if (this.maps.isTileMap && this.isTouch && e['touches'].length > 1) {
|
|
2194
|
-
const startTouch: MapLocation = this.getMousePosition(e['touches'][0].pageX, e['touches'][0].pageY);
|
|
2195
|
-
const endTouch: MapLocation = this.getMousePosition(e['touches'][1].pageX, e['touches'][1].pageY);
|
|
2196
|
-
this.startDistance = Math.sqrt(Math.pow((startTouch.x - endTouch.x), 2) + Math.pow((startTouch.y - endTouch.y), 2));
|
|
2197
|
-
this.touchCenter = { x: (startTouch.x + endTouch.x) / 2, y: (startTouch.y + endTouch.y) / 2 };
|
|
2198
|
-
this.pinchStartLatLong = this.maps.pointToLatLong((startTouch.x + endTouch.x) / 2, (startTouch.y + endTouch.y) / 2);
|
|
2199
|
-
this.isCancellation = false;
|
|
2200
|
-
this.pinchTileZoomScale = this.maps.tileZoomLevel;
|
|
2201
|
-
this.pinchDistance = null;
|
|
2202
|
-
}
|
|
2203
|
-
this.isSingleClick = true;
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
/**
|
|
2207
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
2208
|
-
* @returns {void}
|
|
2209
|
-
* @private
|
|
2210
|
-
*/
|
|
2211
|
-
public mouseMoveHandler(e: PointerEvent | TouchEvent): void {
|
|
2212
|
-
let pageX: number;
|
|
2213
|
-
let pageY: number;
|
|
2214
|
-
const map: Maps = this.maps;
|
|
2215
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2216
|
-
let touchArg: TouchEvent;
|
|
2217
|
-
let target: Element;
|
|
2218
|
-
let touches: TouchList = null;
|
|
2219
|
-
const zoom: ZoomSettings = <ZoomSettings>this.maps.zoomSettings;
|
|
2220
|
-
if (e.type === 'touchmove') {
|
|
2221
|
-
this.isTouch = true;
|
|
2222
|
-
target = <Element>(<TouchEvent & PointerEvent>e).target;
|
|
2223
|
-
touches = (<TouchEvent & PointerEvent>e).touches;
|
|
2224
|
-
pageX = touches[0].pageX;
|
|
2225
|
-
pageY = touches[0].pageY;
|
|
2226
|
-
} else {
|
|
2227
|
-
pageX = (<PointerEvent>e).pageX;
|
|
2228
|
-
pageY = (<PointerEvent>e).pageY;
|
|
2229
|
-
target = <Element>e.target;
|
|
2230
|
-
}
|
|
2231
|
-
if (getElementByID(map.element.id + '_Zooming_KitCollection')) {
|
|
2232
|
-
if (target.id.indexOf('_Zooming_') > -1) {
|
|
2233
|
-
getElementByID(map.element.id + '_Zooming_KitCollection').setAttribute('opacity', '1');
|
|
2234
|
-
}
|
|
2235
|
-
else if (!map.isDevice) {
|
|
2236
|
-
getElementByID(map.element.id + '_Zooming_KitCollection').setAttribute('opacity', map.theme.toLowerCase() === 'fluentdark' ? '0.6' : '0.3');
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
if (this.isTouch) {
|
|
2240
|
-
if (this.maps.zoomSettings.enable && this.maps.zoomSettings.pinchZooming && touches !== null) {
|
|
2241
|
-
if (this.firstMove && touches.length === 2) {
|
|
2242
|
-
this.rectZoomingStart = false;
|
|
2243
|
-
this.updateInteraction();
|
|
2244
|
-
this.touchStartList = targetTouches(e);
|
|
2245
|
-
} else if (touches.length === 2 && this.touchStartList.length === 2) {
|
|
2246
|
-
this.touchMoveList = targetTouches(e);
|
|
2247
|
-
if (e.cancelable) { e.preventDefault(); }
|
|
2248
|
-
this.rectZoomingStart = false;
|
|
2249
|
-
this.performPinchZooming(<PointerEvent>e);
|
|
2250
|
-
}
|
|
2251
|
-
this.firstMove = false;
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
this.mouseMovePoints = this.getMousePosition(pageX, pageY);
|
|
2255
|
-
if (!this.isPinchZooming && (zoom.enable && this.isPanModeEnabled && this.maps.markerDragId.indexOf('_MarkerIndex_') === -1 && ((Browser.isDevice && touches.length >= 1) || !Browser.isDevice))) {
|
|
2256
|
-
e.preventDefault();
|
|
2257
|
-
this.maps.element.style.cursor = 'pointer';
|
|
2258
|
-
this.mouseMoveLatLong = { x: pageX, y: pageY };
|
|
2259
|
-
if ((this.mouseDownLatLong['x'] !== this.mouseMoveLatLong['x']) && (this.mouseDownLatLong['y'] !== this.mouseMoveLatLong['y'])) {
|
|
2260
|
-
if (this.maps.zoomSettings.enablePanning) {
|
|
2261
|
-
this.panning('None', null, null, e);
|
|
2262
|
-
}
|
|
2263
|
-
this.mouseDownLatLong['x'] = pageX;
|
|
2264
|
-
this.mouseDownLatLong['y'] = pageY;
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
if (!this.isPinchZooming && (this.isTouch ? (touches !== null && touches.length === 1 && this.rectZoomingStart) : this.rectZoomingStart)) {
|
|
2268
|
-
e.preventDefault();
|
|
2269
|
-
const scale : number = this.maps.isTileMap ? Math.round(this.maps.tileZoomLevel) : Math.round(this.maps.mapScaleValue);
|
|
2270
|
-
if (this.maps.zoomSettings.enableSelectionZooming && scale < this.maps.zoomSettings.maxZoom) {
|
|
2271
|
-
this.drawZoomRectangle();
|
|
2272
|
-
}
|
|
2273
|
-
else {
|
|
2274
|
-
this.rectZoomingStart = false;
|
|
2275
|
-
this.isPan = true;
|
|
2276
|
-
}
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
/**
|
|
2281
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
2282
|
-
* @returns {void}
|
|
2283
|
-
* @private
|
|
2284
|
-
*/
|
|
2285
|
-
public mouseUpHandler(e: PointerEvent | TouchEvent): void {
|
|
2286
|
-
this.rectZoomingStart = false;
|
|
2287
|
-
this.isSingleClick = this.isSingleClick ? true : false;
|
|
2288
|
-
this.isTouch = false;
|
|
2289
|
-
this.touchStartList = [];
|
|
2290
|
-
this.touchMoveList = [];
|
|
2291
|
-
this.lastScale = 1;
|
|
2292
|
-
this.isCancellation = false;
|
|
2293
|
-
this.maps.element.style.cursor = 'auto';
|
|
2294
|
-
if (this.isPinchZooming && this.maps.isTileMap) {
|
|
2295
|
-
this.isPinchZooming = false;
|
|
2296
|
-
const tilesParent: HTMLElement = document.getElementById(this.maps.element.id + '_tile_parent');
|
|
2297
|
-
const svgElement: HTMLElement = document.getElementById(this.maps.element.id + '_Tile_SVG_Parent');
|
|
2298
|
-
tilesParent.style.transformOrigin = '';
|
|
2299
|
-
tilesParent.style.transform = '';
|
|
2300
|
-
svgElement.style.transformOrigin = '';
|
|
2301
|
-
svgElement.style.transform = '';
|
|
2302
|
-
this.maps.tileZoomLevel = this.maps.mapScaleValue = this.maps.zoomSettings.zoomFactor = this.pinchZoomScale;
|
|
2303
|
-
this.maps.scale = Math.pow(2, this.pinchZoomScale - 1);
|
|
2304
|
-
this.tileZoomLevel = Math.round(this.pinchZoomScale);
|
|
2305
|
-
this.getTileTranslate(this.tileZoomLevel);
|
|
2306
|
-
this.maps.mapLayerPanel.generateTiles(this.tileZoomLevel, this.maps.tileTranslatePoint);
|
|
2307
|
-
this.applyTransform(this.maps);
|
|
2308
|
-
if (document.getElementById(this.maps.element.id + '_animates_tiles')) {
|
|
2309
|
-
document.getElementById(this.maps.element.id + '_animates_tiles').remove();
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
if (this.isPanModeEnabled && this.maps.zoomSettings.enablePanning && !isNullOrUndefined(this.maps.previousPoint) &&
|
|
2313
|
-
(!this.maps.isTileMap ? (this.maps.translatePoint.x !== this.maps.previousPoint.x && this.maps.translatePoint.y !== this.maps.previousPoint.y)
|
|
2314
|
-
: this.isPanningInProgress)) {
|
|
2315
|
-
let pageX: number;
|
|
2316
|
-
let pageY: number;
|
|
2317
|
-
let layerX: number = 0;
|
|
2318
|
-
let layerY: number = 0;
|
|
2319
|
-
let target: Element;
|
|
2320
|
-
const element: Element = <Element>e.target;
|
|
2321
|
-
if (e.type.indexOf('touch') !== - 1) {
|
|
2322
|
-
const touchArg: TouchEvent = <TouchEvent & PointerEvent>e;
|
|
2323
|
-
layerX = pageX = touchArg.changedTouches[0].pageX;
|
|
2324
|
-
pageY = touchArg.changedTouches[0].pageY;
|
|
2325
|
-
layerY = pageY - (this.maps.isTileMap ? 10 : 0);
|
|
2326
|
-
target = <Element>touchArg.target;
|
|
2327
|
-
this.maps.mouseClickEvent = { x: pageX, y: pageY };
|
|
2328
|
-
} else {
|
|
2329
|
-
pageX = (e as PointerEvent).pageX;
|
|
2330
|
-
pageY = (e as PointerEvent).pageY;
|
|
2331
|
-
layerX = e['layerX'];
|
|
2332
|
-
layerY = e['layerY'] - (this.maps.isTileMap ? 10 : 0);
|
|
2333
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2334
|
-
target = <Element>e.target;
|
|
2335
|
-
}
|
|
2336
|
-
let panCompleteEventArgs: IMapPanEventArgs;
|
|
2337
|
-
const minMaxLatitudeLongitude: IMinMaxLatitudeLongitude = this.maps.getMinMaxLatitudeLongitude();
|
|
2338
|
-
if (!this.maps.isTileMap) {
|
|
2339
|
-
this.maps.mouseClickEvent['x'] = this.maps.mouseDownEvent['x'];
|
|
2340
|
-
this.maps.mouseClickEvent['y'] = this.maps.mouseDownEvent['y'];
|
|
2341
|
-
const location: GeoPosition = this.maps.getClickLocation(element.id, pageX, pageY, (element as HTMLElement), pageX, pageY);
|
|
2342
|
-
panCompleteEventArgs = {
|
|
2343
|
-
cancel: false, name: 'panComplete', maps: this.maps,
|
|
2344
|
-
tileTranslatePoint: {}, translatePoint: { previous: this.maps.previousPoint, current: this.maps.translatePoint },
|
|
2345
|
-
scale: this.maps.scale, tileZoomLevel: this.maps.tileZoomLevel, latitude: !isNullOrUndefined(location) ?
|
|
2346
|
-
location.latitude : 0, longitude: !isNullOrUndefined(location) ? location.longitude : 0,
|
|
2347
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
2348
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
2349
|
-
};
|
|
2350
|
-
} else {
|
|
2351
|
-
const location: GeoPosition = this.maps.getTileGeoLocation(layerX, layerY);
|
|
2352
|
-
panCompleteEventArgs = {
|
|
2353
|
-
cancel: false, name: 'panComplete', maps: this.maps,
|
|
2354
|
-
tileTranslatePoint: { previous: this.maps.tileTranslatePoint , current: this.maps.tileTranslatePoint },
|
|
2355
|
-
translatePoint: { previous: this.maps.previousPoint, current: this.maps.translatePoint}, scale: this.maps.scale,
|
|
2356
|
-
tileZoomLevel: this.maps.tileZoomLevel, latitude: location.latitude, longitude: location.longitude,
|
|
2357
|
-
minLatitude: minMaxLatitudeLongitude.minLatitude, maxLatitude: minMaxLatitudeLongitude.maxLatitude,
|
|
2358
|
-
minLongitude: minMaxLatitudeLongitude.minLongitude, maxLongitude: minMaxLatitudeLongitude.maxLongitude
|
|
2359
|
-
};
|
|
2360
|
-
}
|
|
2361
|
-
this.maps.trigger('panComplete', panCompleteEventArgs);
|
|
2362
|
-
}
|
|
2363
|
-
this.isPanModeEnabled = false;
|
|
2364
|
-
this.isPanningInProgress = false;
|
|
2365
|
-
const zoomRectElement: HTMLElement = <HTMLElement>getElementByID(this.maps.element.id + '_Selection_Rect_Zooming');
|
|
2366
|
-
if (zoomRectElement && this.maps.zoomSettings.enable && this.maps.zoomSettings.enableSelectionZooming) {
|
|
2367
|
-
remove(zoomRectElement);
|
|
2368
|
-
this.performRectZooming();
|
|
2369
|
-
}
|
|
2370
|
-
this.mouseMoveLatLong = { x: 0, y: 0 };
|
|
2371
|
-
this.mouseDownLatLong = { x: 0, y: 0 };
|
|
2372
|
-
this.pinchDistance = null;
|
|
2373
|
-
}
|
|
2374
|
-
|
|
2375
|
-
/**
|
|
2376
|
-
* @param {PointerEvent} e - Specifies the event in the map
|
|
2377
|
-
* @returns {void}
|
|
2378
|
-
* @private
|
|
2379
|
-
*/
|
|
2380
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2381
|
-
public mouseCancelHandler(e: PointerEvent): void {
|
|
2382
|
-
this.isPanModeEnabled = false;
|
|
2383
|
-
this.isTouch = false;
|
|
2384
|
-
this.rectZoomingStart = false;
|
|
2385
|
-
const zoomRectElement: HTMLElement = <HTMLElement>getElementByID(this.maps.element.id + '_Selection_Rect_Zooming');
|
|
2386
|
-
if (zoomRectElement && this.maps.zoomSettings.enable) {
|
|
2387
|
-
remove(zoomRectElement);
|
|
2388
|
-
this.performRectZooming();
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* To handle the click event for maps.
|
|
2393
|
-
*
|
|
2394
|
-
* @param {PointerEvent} e - Specifies the pointer event.
|
|
2395
|
-
* @returns {void}
|
|
2396
|
-
* @private
|
|
2397
|
-
*/
|
|
2398
|
-
public click(e: PointerEvent): void {
|
|
2399
|
-
const map: Maps = this.maps;
|
|
2400
|
-
const tooltipElement: Element = (e.target as HTMLElement).closest('#' + this.maps.element.id + '_mapsTooltipparent_template');
|
|
2401
|
-
if ((map.markerModule && map.markerModule.sameMarkerData.length > 0) ||
|
|
2402
|
-
(e.target['id'].indexOf('MarkerIndex') > -1 && e.target['id'].indexOf('cluster') === -1) || !isNullOrUndefined(tooltipElement)) {
|
|
2403
|
-
return null;
|
|
2404
|
-
}
|
|
2405
|
-
if (this.isSingleClick && map.zoomSettings.zoomOnClick && !(e.target['id'].indexOf('_Zooming_') > -1) && !map.zoomSettings.doubleClickZoom
|
|
2406
|
-
&& (this.zoomColor !== this.selectionColor)) {
|
|
2407
|
-
const pageX: number = e.pageX;
|
|
2408
|
-
const pageY: number = e.pageY;
|
|
2409
|
-
const position: Point = this.getMousePosition(pageX, pageY);
|
|
2410
|
-
const prevLevel: number = map.tileZoomLevel;
|
|
2411
|
-
const prevScale: number = map.scale;
|
|
2412
|
-
map.mapScaleValue = map.mapScaleValue + 1;
|
|
2413
|
-
const value: number = (map.isTileMap) ? prevLevel : prevScale;
|
|
2414
|
-
if (((position.x > map.mapAreaRect.x) && (position.x < (map.mapAreaRect.x + map.mapAreaRect.width))) &&
|
|
2415
|
-
(position.y > map.mapAreaRect.y) && position.y < (map.mapAreaRect.y + map.mapAreaRect.height)) {
|
|
2416
|
-
this.performZooming(position, (value + 1), 'ZoomIn');
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
|
|
2421
|
-
/**
|
|
2422
|
-
* Gets the Mouse Position.
|
|
2423
|
-
*
|
|
2424
|
-
* @param {number} pageX - Specifies the Page x in map
|
|
2425
|
-
* @param {number} pageY - Specifies the Page y in map
|
|
2426
|
-
* @returns {Point} - returns the mouse point position
|
|
2427
|
-
* @private
|
|
2428
|
-
*/
|
|
2429
|
-
public getMousePosition(pageX: number, pageY: number): Point {
|
|
2430
|
-
const map: Maps = this.maps;
|
|
2431
|
-
const elementRect: ClientRect = map.element.getBoundingClientRect();
|
|
2432
|
-
const pageXOffset: number = map.element.ownerDocument.defaultView.pageXOffset;
|
|
2433
|
-
const pageYOffset: number = map.element.ownerDocument.defaultView.pageYOffset;
|
|
2434
|
-
const clientTop: number = map.element.ownerDocument.documentElement.clientTop;
|
|
2435
|
-
const clientLeft: number = map.element.ownerDocument.documentElement.clientLeft;
|
|
2436
|
-
const positionX: number = elementRect.left + pageXOffset - clientLeft;
|
|
2437
|
-
const positionY: number = elementRect.top + pageYOffset - clientTop;
|
|
2438
|
-
return new Point(Math.abs(pageX - positionX), Math.abs(pageY - positionY));
|
|
2439
|
-
}
|
|
2440
|
-
|
|
2441
|
-
/**
|
|
2442
|
-
* @returns {void}
|
|
2443
|
-
* @private
|
|
2444
|
-
*/
|
|
2445
|
-
public addEventListener(): void {
|
|
2446
|
-
if (this.maps.isDestroyed) {
|
|
2447
|
-
return;
|
|
2448
|
-
}
|
|
2449
|
-
EventHandler.add(this.maps.element, this.wheelEvent, this.mapMouseWheel, this);
|
|
2450
|
-
EventHandler.add(this.maps.element, 'click', this.click, this);
|
|
2451
|
-
EventHandler.add(this.maps.element, 'dblclick', this.doubleClick, this);
|
|
2452
|
-
this.maps.on(Browser.touchMoveEvent, this.mouseMoveHandler, this);
|
|
2453
|
-
this.maps.on(Browser.touchStartEvent, this.mouseDownHandler, this);
|
|
2454
|
-
this.maps.on(Browser.touchEndEvent, this.mouseUpHandler, this);
|
|
2455
|
-
EventHandler.add(this.maps.element, this.cancelEvent, this.mouseCancelHandler, this);
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
/**
|
|
2459
|
-
* @returns {void}
|
|
2460
|
-
* @private
|
|
2461
|
-
*/
|
|
2462
|
-
public removeEventListener(): void {
|
|
2463
|
-
if (this.maps.isDestroyed) {
|
|
2464
|
-
return;
|
|
2465
|
-
}
|
|
2466
|
-
EventHandler.remove(this.maps.element, this.wheelEvent, this.mapMouseWheel);
|
|
2467
|
-
EventHandler.remove(this.maps.element, 'click', this.click);
|
|
2468
|
-
EventHandler.remove(this.maps.element, 'dblclick', this.doubleClick);
|
|
2469
|
-
this.maps.off(Browser.touchMoveEvent, this.mouseMoveHandler);
|
|
2470
|
-
this.maps.off(Browser.touchStartEvent, this.mouseDownHandler);
|
|
2471
|
-
this.maps.off(Browser.touchEndEvent, this.mouseUpHandler);
|
|
2472
|
-
EventHandler.remove(this.maps.element, this.cancelEvent, this.mouseCancelHandler);
|
|
2473
|
-
const toolbarElement: HTMLElement = document.getElementById(this.maps.element.id + '_Zooming_KitCollection');
|
|
2474
|
-
if (toolbarElement) {
|
|
2475
|
-
for (let i: number = 0; i < toolbarElement.childNodes.length; i++) {
|
|
2476
|
-
if ((toolbarElement.childNodes[i as number] as HTMLElement).tagName === 'g') {
|
|
2477
|
-
EventHandler.add((toolbarElement.childNodes[i as number] as HTMLElement), Browser.touchStartEvent, this.performToolBarAction);
|
|
2478
|
-
EventHandler.add((toolbarElement.childNodes[i as number] as HTMLElement), 'mouseover', this.showTooltip);
|
|
2479
|
-
EventHandler.add((toolbarElement.childNodes[i as number] as HTMLElement), 'mouseout', this.removeTooltip);
|
|
2480
|
-
}
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
}
|
|
2484
|
-
|
|
2485
|
-
/**
|
|
2486
|
-
* Get module name.
|
|
2487
|
-
*
|
|
2488
|
-
* @returns {string} - Returns the module name.
|
|
2489
|
-
*/
|
|
2490
|
-
protected getModuleName(): string {
|
|
2491
|
-
return 'Zoom';
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
/**
|
|
2495
|
-
* To destroy the zoom.
|
|
2496
|
-
*
|
|
2497
|
-
* @returns {void}
|
|
2498
|
-
* @private
|
|
2499
|
-
*/
|
|
2500
|
-
public destroy(): void {
|
|
2501
|
-
this.toolBarGroup = null;
|
|
2502
|
-
this.currentToolbarEle = null;
|
|
2503
|
-
this.zoomingRect = null;
|
|
2504
|
-
this.zoomElements = null;
|
|
2505
|
-
this.panElements = null;
|
|
2506
|
-
this.baseTranslatePoint = null;
|
|
2507
|
-
this.touchStartList = null;
|
|
2508
|
-
this.touchMoveList = null;
|
|
2509
|
-
this.previousTouchMoveList = null;
|
|
2510
|
-
this.mouseDownPoints = null;
|
|
2511
|
-
this.mouseMovePoints = null;
|
|
2512
|
-
this.startTouches = [];
|
|
2513
|
-
this.mouseDownLatLong = null;
|
|
2514
|
-
this.mouseMoveLatLong = null;
|
|
2515
|
-
this.layerCollectionEle = null;
|
|
2516
|
-
this.currentLayer = null;
|
|
2517
|
-
this.pinchDistance = null;
|
|
2518
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2519
|
-
if (!(this.maps as any).refreshing) {
|
|
2520
|
-
this.maps = null;
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
}
|