@syncfusion/ej2-maps 31.1.17 → 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.
Files changed (67) hide show
  1. package/README.md +11 -2
  2. package/dist/ej2-maps.min.js +3 -3
  3. package/dist/ej2-maps.umd.min.js +3 -3
  4. package/dist/ej2-maps.umd.min.js.map +1 -1
  5. package/dist/es6/ej2-maps.es2015.js +84 -53
  6. package/dist/es6/ej2-maps.es2015.js.map +1 -1
  7. package/dist/es6/ej2-maps.es5.js +87 -56
  8. package/dist/es6/ej2-maps.es5.js.map +1 -1
  9. package/dist/global/ej2-maps.min.js +3 -3
  10. package/dist/global/ej2-maps.min.js.map +1 -1
  11. package/dist/global/index.d.ts +2 -2
  12. package/package.json +18 -53
  13. package/src/maps/layers/layer-panel.js +86 -55
  14. package/dist/ts/index.d.ts +0 -4
  15. package/dist/ts/index.ts +0 -4
  16. package/dist/ts/maps/index.d.ts +0 -28
  17. package/dist/ts/maps/index.ts +0 -28
  18. package/dist/ts/maps/layers/bing-map.d.ts +0 -21
  19. package/dist/ts/maps/layers/bing-map.ts +0 -51
  20. package/dist/ts/maps/layers/bubble.d.ts +0 -77
  21. package/dist/ts/maps/layers/bubble.ts +0 -304
  22. package/dist/ts/maps/layers/color-mapping.d.ts +0 -36
  23. package/dist/ts/maps/layers/color-mapping.ts +0 -230
  24. package/dist/ts/maps/layers/data-label.d.ts +0 -45
  25. package/dist/ts/maps/layers/data-label.ts +0 -457
  26. package/dist/ts/maps/layers/layer-panel.d.ts +0 -144
  27. package/dist/ts/maps/layers/layer-panel.ts +0 -1455
  28. package/dist/ts/maps/layers/legend.d.ts +0 -173
  29. package/dist/ts/maps/layers/legend.ts +0 -2465
  30. package/dist/ts/maps/layers/marker.d.ts +0 -105
  31. package/dist/ts/maps/layers/marker.ts +0 -632
  32. package/dist/ts/maps/layers/navigation-selected-line.d.ts +0 -33
  33. package/dist/ts/maps/layers/navigation-selected-line.ts +0 -171
  34. package/dist/ts/maps/layers/polygon.d.ts +0 -30
  35. package/dist/ts/maps/layers/polygon.ts +0 -68
  36. package/dist/ts/maps/maps-model.d.ts +0 -409
  37. package/dist/ts/maps/maps.d.ts +0 -1247
  38. package/dist/ts/maps/maps.ts +0 -3416
  39. package/dist/ts/maps/model/base-model.d.ts +0 -2107
  40. package/dist/ts/maps/model/base.d.ts +0 -1840
  41. package/dist/ts/maps/model/base.ts +0 -2257
  42. package/dist/ts/maps/model/constants.d.ts +0 -225
  43. package/dist/ts/maps/model/constants.ts +0 -226
  44. package/dist/ts/maps/model/export-image.d.ts +0 -39
  45. package/dist/ts/maps/model/export-image.ts +0 -194
  46. package/dist/ts/maps/model/export-pdf.d.ts +0 -40
  47. package/dist/ts/maps/model/export-pdf.ts +0 -183
  48. package/dist/ts/maps/model/interface.d.ts +0 -892
  49. package/dist/ts/maps/model/interface.ts +0 -929
  50. package/dist/ts/maps/model/print.d.ts +0 -45
  51. package/dist/ts/maps/model/print.ts +0 -125
  52. package/dist/ts/maps/model/theme.d.ts +0 -98
  53. package/dist/ts/maps/model/theme.ts +0 -919
  54. package/dist/ts/maps/user-interaction/annotation.d.ts +0 -27
  55. package/dist/ts/maps/user-interaction/annotation.ts +0 -133
  56. package/dist/ts/maps/user-interaction/highlight.d.ts +0 -63
  57. package/dist/ts/maps/user-interaction/highlight.ts +0 -272
  58. package/dist/ts/maps/user-interaction/selection.d.ts +0 -85
  59. package/dist/ts/maps/user-interaction/selection.ts +0 -342
  60. package/dist/ts/maps/user-interaction/tooltip.d.ts +0 -78
  61. package/dist/ts/maps/user-interaction/tooltip.ts +0 -500
  62. package/dist/ts/maps/user-interaction/zoom.d.ts +0 -334
  63. package/dist/ts/maps/user-interaction/zoom.ts +0 -2523
  64. package/dist/ts/maps/utils/enum.d.ts +0 -328
  65. package/dist/ts/maps/utils/enum.ts +0 -343
  66. package/dist/ts/maps/utils/helper.d.ts +0 -1318
  67. package/dist/ts/maps/utils/helper.ts +0 -3811
@@ -1,632 +0,0 @@
1
- import { Maps } from '../../index';
2
- import {
3
- LayerSettings, MarkerSettings, IMarkerRenderingEventArgs, markerRendering,
4
- convertTileLatLongToPoint, MapLocation, MarkerClusterData, markerDragStart,
5
- MarkerClusterSettingsModel
6
- } from '../index';
7
- import {
8
- IMarkerClickEventArgs, markerClick, IMarkerMoveEventArgs, markerMouseMove,
9
- IMarkerClusterClickEventArgs, IMarkerClusterMoveEventArgs, markerClusterClick, markerClusterMouseMove,
10
- MarkerSettingsModel, IMarkerDragEventArgs
11
- } from '../index';
12
- import { isNullOrUndefined, createElement, animationMode } from '@syncfusion/ej2-base';
13
- import { Point, getTranslate, convertGeoToPoint, clusterTemplate, marker, markerTemplate, getZoomTranslate } from '../utils/helper';
14
- import {
15
- getElementByID, mergeSeparateCluster, clusterSeparate, removeElement, getElement,
16
- markerColorChoose, markerShapeChoose, calculateZoomLevel, compareZoomFactor, getValueFromObject
17
- } from '../utils/helper';
18
-
19
- /**
20
- * Marker class
21
- */
22
- export class Marker {
23
- private maps: Maps;
24
- private isMarkerExplode: number;
25
- private markerSVGObject: Element;
26
- public initialMarkerCluster: number[][][];
27
- public zoomedMarkerCluster: number[][][];
28
- /**
29
- * @private
30
- */
31
- public sameMarkerData: MarkerClusterData[];
32
- constructor(maps: Maps) {
33
- this.maps = maps;
34
- this.sameMarkerData = [];
35
- this.initialMarkerCluster = [];
36
- this.zoomedMarkerCluster = [];
37
- }
38
- /**
39
- * @private
40
- * @returns {Maps} - Returns the instance of the map.
41
- */
42
- public getMapsInstance(): Maps{
43
- return this.maps;
44
- }
45
- public markerRender(maps: Maps, layerElement: Element, layerIndex: number, factor: number, type: string): void {
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- let templateFn: any;
48
- let markerCount: number = 0;
49
- let nullCount: number = 0;
50
- let isMarkerTemplateNewCreation: boolean = false;
51
- let markerTemplateCount: number = 0; maps.translateType = 'marker';
52
- const currentLayer: LayerSettings = <LayerSettings>maps.layersCollection[layerIndex as number];
53
- const markerElement: NodeListOf<Element> = layerElement.querySelectorAll('#' + maps.element.id + '_Markers_Group');
54
- if (markerElement.length > 0) {
55
- this.markerSVGObject = markerElement[0];
56
- this.markerSVGObject.innerHTML = '';
57
- isMarkerTemplateNewCreation = true;
58
- } else {
59
- this.markerSVGObject = maps.renderer.createGroup({
60
- id: maps.element.id + '_Markers_Group',
61
- class: 'GroupElement'
62
- });
63
- }
64
- (this.markerSVGObject as HTMLElement).style.pointerEvents = 'auto';
65
- const secondaryElement: Element = getElementByID(maps.element.id + '_Secondary_Element');
66
- const markerTemplateElement: NodeListOf<Element> = secondaryElement.querySelectorAll('#' + maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group');
67
- let markerTemplateEle: HTMLElement;
68
- if (markerTemplateElement && markerTemplateElement.length > 0 && markerTemplateElement[0].childElementCount > 0) {
69
- markerTemplateEle = getElementByID(maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group') as HTMLElement;
70
- markerTemplateEle.innerHTML = '';
71
- isMarkerTemplateNewCreation = true;
72
- } else {
73
- markerTemplateEle = createElement('div', {
74
- id: maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group',
75
- className: maps.element.id + '_template'
76
- });
77
- markerTemplateEle.style.cssText = 'overflow: hidden; position: absolute;pointer-events: none;' +
78
- 'top:' + maps.mapAreaRect.y + 'px;' +
79
- 'left:' + maps.mapAreaRect.x + 'px;' +
80
- 'height:' + maps.mapAreaRect.height + 'px;' +
81
- 'width:' + maps.mapAreaRect.width + 'px;';
82
- }
83
- const allowInnerClusterSetting: boolean = this.allowInnerClusterSetting(currentLayer);
84
- const allowAnimation: boolean = (currentLayer.animationDuration !== 0 || animationMode === 'Enable') || isNullOrUndefined(maps.zoomModule);
85
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
- let translatePoint: any;
87
- if (!maps.isTileMap) {
88
- translatePoint = !isNullOrUndefined(maps.zoomModule) && maps.zoomSettings.zoomFactor > 1 ?
89
- getZoomTranslate(maps, currentLayer, allowAnimation) :
90
- getTranslate(maps, currentLayer, allowAnimation);
91
- }
92
- Array.prototype.forEach.call(currentLayer.markerSettings, (markerSettings: MarkerSettingsModel, markerIndex: number) => {
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- const markerData: any[] = <any[]>markerSettings.dataSource;
95
- markerCount = 0;
96
- if (!isNullOrUndefined(markerSettings.dataSource)) {
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- Array.prototype.forEach.call(markerData, (data: any, dataIndex: number) => {
99
- maps.markerNullCount = markerIndex > 0 && dataIndex === 0 ? 0 : maps.markerNullCount;
100
- let eventArgs: IMarkerRenderingEventArgs = {
101
- cancel: false, name: markerRendering, fill: markerSettings.fill,
102
- height: (!isNullOrUndefined(markerSettings.heightValuePath) &&
103
- !isNullOrUndefined(data[markerSettings.heightValuePath]) ?
104
- data[markerSettings.heightValuePath] : markerSettings.height),
105
- width: (!isNullOrUndefined(markerSettings.widthValuePath) &&
106
- !isNullOrUndefined(data[markerSettings.widthValuePath]) ?
107
- data[markerSettings.widthValuePath] : markerSettings.width),
108
- imageUrl: markerSettings.imageUrl, shape: markerSettings.shape,
109
- template: markerSettings.template, data: data, maps: maps, marker: markerSettings,
110
- border: markerSettings.border, colorValuePath: markerSettings.colorValuePath,
111
- shapeValuePath: markerSettings.shapeValuePath, imageUrlValuePath: markerSettings.imageUrlValuePath
112
- };
113
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
- maps.trigger('markerRendering', eventArgs, (MarkerArgs: IMarkerRenderingEventArgs) => {
115
- eventArgs = markerColorChoose(eventArgs, data);
116
- eventArgs = markerShapeChoose(eventArgs, data);
117
- const lng: number = (!isNullOrUndefined(markerSettings.longitudeValuePath)) ?
118
- Number(getValueFromObject(data, markerSettings.longitudeValuePath)) : !isNullOrUndefined(data['longitude']) ?
119
- parseFloat(data['longitude']) : !isNullOrUndefined(data['Longitude']) ? parseFloat(data['Longitude']) : null;
120
- const lat: number = (!isNullOrUndefined(markerSettings.latitudeValuePath)) ?
121
- Number(getValueFromObject(data, markerSettings.latitudeValuePath)) : !isNullOrUndefined(data['latitude']) ?
122
- parseFloat(data['latitude']) : !isNullOrUndefined(data['Latitude']) ? parseFloat(data['Latitude']) : null;
123
- const offset: Point = markerSettings.offset;
124
- if (!eventArgs.cancel && markerSettings.visible && !isNullOrUndefined(lng) && !isNullOrUndefined(lat)) {
125
- const markerID: string = maps.element.id + '_LayerIndex_' + layerIndex + '_MarkerIndex_'
126
- + markerIndex + '_dataIndex_' + dataIndex;
127
- let location: Point = (maps.isTileMap) ? convertTileLatLongToPoint(
128
- new MapLocation(lng, lat), factor, maps.tileTranslatePoint, true
129
- ) : convertGeoToPoint(lat, lng, factor, currentLayer, maps);
130
- if (maps.isTileMap) {
131
- translatePoint = (currentLayer.type === 'SubLayer' && isNullOrUndefined(maps.zoomModule)) ? location = convertTileLatLongToPoint(
132
- new MapLocation(lng, lat), maps.tileZoomLevel, maps.tileTranslatePoint, true) : new Object();
133
- }
134
- const scale: number = type === 'AddMarker' ? maps.scale : translatePoint['scale'];
135
- const transPoint: Point = type === 'AddMarker' ? maps.translatePoint : translatePoint['location'] as Point;
136
- if (eventArgs.template && (!isNaN(location.x) && !isNaN(location.y))) {
137
- isMarkerTemplateNewCreation = false;
138
- markerTemplateCount++;
139
- markerTemplate(eventArgs, templateFn, markerID, data, markerIndex, markerTemplateEle, location, transPoint,
140
- scale, offset, maps);
141
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
- (maps as any).renderReactTemplates();
143
- } else if (!eventArgs.template && (!isNaN(location.x) && !isNaN(location.y))) {
144
- isMarkerTemplateNewCreation = true;
145
- markerCount++;
146
- marker(eventArgs, markerSettings as MarkerSettings, markerData, dataIndex,
147
- location, transPoint, markerID, offset, scale, maps, this.markerSVGObject);
148
- }
149
- }
150
- nullCount += (!isNaN(lat) && !isNaN(lng)) ? 0 : 1;
151
- markerTemplateCount += (eventArgs.cancel) ? 1 : 0;
152
- markerCount += (eventArgs.cancel) ? 1 : 0;
153
- maps.markerNullCount = (isNullOrUndefined(lng) || isNullOrUndefined(lat)) ?
154
- maps.markerNullCount + 1 : maps.markerNullCount;
155
- const markerDataLength: number = markerData.length - maps.markerNullCount;
156
- let isMarkersClustered: boolean = false;
157
- const markerGroup: NodeListOf<Element> | NodeListOf<ChildNode> =
158
- (markerSettings.clusterSettings.allowClustering ||
159
- (currentLayer.markerClusterSettings.allowClustering && currentLayer.markerSettings.length > 1))
160
- ? this.markerSVGObject.querySelectorAll(`[id*='LayerIndex_${layerIndex}_MarkerIndex_${markerIndex}']:not([id*='_Group'])`)
161
- : this.markerSVGObject.childNodes;
162
- const templateCount: number = this.markerSVGObject.childNodes === markerGroup ? markerTemplateCount : 0;
163
- if (markerGroup.length === (markerDataLength - templateCount - nullCount) && (type !== 'Template')) {
164
- if (markerElement.length === 0) {
165
- layerElement.appendChild(this.markerSVGObject);
166
- }
167
- if (markerSettings.clusterSettings.allowClustering || !allowInnerClusterSetting &&
168
- currentLayer.markerClusterSettings.allowClustering) {
169
- if (markerElement.length === 0) {
170
- maps.svgObject.appendChild(this.markerSVGObject);
171
- maps.element.appendChild(maps.svgObject);
172
- }
173
- if ((currentLayer.urlTemplate.indexOf('openstreetmap') !== -1 && isNullOrUndefined(currentLayer.shapeData))
174
- && maps.zoomSettings.enable) {
175
- isMarkersClustered = clusterTemplate(currentLayer, this.markerSVGObject, maps, layerIndex, markerIndex,
176
- this.markerSVGObject, layerElement, true, false, null,
177
- allowInnerClusterSetting);
178
- if (markerElement.length === 0) {
179
- layerElement.appendChild(this.markerSVGObject);
180
- }
181
- } else {
182
- isMarkersClustered = clusterTemplate(currentLayer, this.markerSVGObject, maps, layerIndex,
183
- markerIndex, this.markerSVGObject, layerElement,
184
- true, false, translatePoint, allowInnerClusterSetting);
185
- }
186
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
- (maps as any).renderReactTemplates();
188
- }
189
- }
190
- const markerTemplateGroup: NodeListOf<Element> | NodeListOf<ChildNode> =
191
- (markerSettings.clusterSettings.allowClustering ||
192
- (currentLayer.markerClusterSettings.allowClustering && currentLayer.markerSettings.length > 1))
193
- ? markerTemplateEle.querySelectorAll(`[id*='LayerIndex_${layerIndex}_MarkerIndex_${markerIndex}']:not([id*='_Group'])`)
194
- : markerTemplateEle.childNodes;
195
- if (markerTemplateGroup.length === (markerDataLength - markerCount - nullCount) && getElementByID(maps.element.id + '_Secondary_Element')) {
196
- if (!isMarkerTemplateNewCreation) {
197
- getElementByID(maps.element.id + '_Secondary_Element').appendChild(markerTemplateEle);
198
- }
199
- if (maps.checkInitialRender) {
200
- if ((markerSettings.clusterSettings.allowClustering || !allowInnerClusterSetting &&
201
- currentLayer.markerClusterSettings.allowClustering) && !isMarkersClustered) {
202
- clusterTemplate(currentLayer, markerTemplateEle, maps,
203
- layerIndex, markerIndex, this.markerSVGObject, layerElement, false, false,
204
- translatePoint, allowInnerClusterSetting);
205
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
- (maps as any).renderReactTemplates();
207
- }
208
- }
209
- if (currentLayer.markerClusterSettings.allowClustering && markerElement.length > 0) {
210
- const layerCollectionEle: Element = getElementByID(maps.element.id + '_Layer_Collections');
211
- layerCollectionEle.appendChild(layerElement);
212
- }
213
- }
214
- });
215
- });
216
- }
217
- });
218
- }
219
- /**
220
- * To find zoom level for individual layers like India, USA.
221
- *
222
- * @param {number} mapWidth - Specifies the width of the maps
223
- * @param {number} mapHeight - Specifies the height of the maps
224
- * @param {number} maxZoomFact - Specifies the maximum zoom factor
225
- * @returns {number} - Returns the scale factor
226
- */
227
- private calculateIndividualLayerMarkerZoomLevel(mapWidth : number, mapHeight : number,
228
- maxZoomFact : number): number {
229
- let latZoom: number; let lngZoom : number;
230
- const height : number = Math.abs(this.maps.baseMapBounds.latitude.max - this.maps.baseMapBounds.latitude.min);
231
- const width : number = Math.abs(this.maps.baseMapBounds.longitude.max - this.maps.baseMapBounds.longitude.min);
232
- latZoom = Math.floor(Math.log(mapHeight / height));
233
- latZoom = (latZoom > maxZoomFact) ? maxZoomFact : latZoom;
234
- lngZoom = Math.floor(Math.log(mapWidth / width));
235
- lngZoom = (lngZoom > maxZoomFact) ? maxZoomFact : lngZoom;
236
- const result: number = Math.min(latZoom, lngZoom);
237
- const scaleFactor: number = Math.min(result, maxZoomFact - 1);
238
- if (!this.maps.isTileMap) {
239
- compareZoomFactor(scaleFactor, this.maps);
240
- }
241
- return scaleFactor;
242
- }
243
- /**
244
- * To calculate center position and factor value dynamically.
245
- *
246
- * @param {LayerSettings[]} layersCollection - Specifies the layer settings instance.
247
- * @returns {void}
248
- * @private
249
- */
250
- public calculateZoomCenterPositionAndFactor(layersCollection: LayerSettings[]): void {
251
- if (!isNullOrUndefined(this.maps)) {
252
- if (this.maps.zoomSettings.shouldZoomInitially && this.maps.markerModule) {
253
- let minLong: number; let maxLat: number; let minLat: number; let maxLong: number;
254
- let zoomLevel: number;
255
- let centerLat: number; let centerLong: number; const maxZoomFact: number = this.maps.zoomSettings.maxZoom;
256
- const mapWidth: number = this.maps.mapAreaRect.width;
257
- const mapHeight: number = this.maps.mapAreaRect.height;
258
- this.maps.markerZoomedState = this.maps.markerZoomedState ? this.maps.markerZoomedState :
259
- isNullOrUndefined(this.maps.markerZoomFactor) ? !this.maps.markerZoomedState :
260
- this.maps.markerZoomFactor > 1 ? this.maps.markerZoomedState : !this.maps.markerZoomedState;
261
- this.maps.defaultState = this.maps.markerZoomedState ? !this.maps.markerZoomedState : this.maps.defaultState;
262
- Array.prototype.forEach.call(layersCollection, (currentLayer: LayerSettings) => {
263
- const isMarker: boolean = currentLayer.markerSettings.length !== 0;
264
- if (isMarker) {
265
- Array.prototype.forEach.call(currentLayer.markerSettings, (markerSetting: MarkerSettingsModel) => {
266
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
267
- const markerData: any[] = <any[]>markerSetting.dataSource;
268
- if (!isNullOrUndefined(markerData) && markerData.length > 0) {
269
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
270
- Array.prototype.forEach.call(markerData, (data: any, dataIndex: number) => {
271
- const latitude: number = !isNullOrUndefined(data['latitude']) ? parseFloat(data['latitude']) :
272
- !isNullOrUndefined(data['Latitude']) ? parseFloat(data['Latitude']) : null;
273
- const longitude: number = !isNullOrUndefined(data['longitude']) ? parseFloat(data['longitude']) :
274
- !isNullOrUndefined(data['Longitude']) ? parseFloat(data['Longitude']) : null;
275
- if (!isNullOrUndefined(latitude) && !isNullOrUndefined(longitude)) {
276
- minLong = isNullOrUndefined(minLong) && dataIndex === 0 ?
277
- longitude : minLong;
278
- maxLat = isNullOrUndefined(maxLat) && dataIndex === 0 ?
279
- latitude : maxLat;
280
- minLat = isNullOrUndefined(minLat) && dataIndex === 0 ?
281
- latitude : minLat;
282
- maxLong = isNullOrUndefined(maxLong) && dataIndex === 0 ?
283
- longitude : maxLong;
284
- if (minLong > longitude) {
285
- minLong = longitude;
286
- }
287
- if (minLat > latitude) {
288
- minLat = latitude;
289
- }
290
- if (maxLong < longitude) {
291
- maxLong = longitude;
292
- }
293
- if (maxLat < latitude) {
294
- maxLat = latitude;
295
- }
296
- }
297
- });
298
- }
299
- });
300
- }
301
- });
302
- if (!isNullOrUndefined(minLat) && !isNullOrUndefined(minLong) &&
303
- !isNullOrUndefined(maxLong) && !isNullOrUndefined(maxLat)) {
304
- // To find the center position
305
- centerLat = (minLat + maxLat) / 2;
306
- centerLong = (minLong + maxLong) / 2;
307
- this.maps.markerCenterLatitude = centerLat;
308
- this.maps.markerCenterLongitude = centerLong;
309
- if (isNullOrUndefined(this.maps.markerZoomCenterPoint) || this.maps.markerZoomedState) {
310
- this.maps.markerZoomCenterPoint = {
311
- latitude: centerLat,
312
- longitude: centerLong
313
- };
314
- }
315
- let markerFactor: number;
316
- if (this.maps.isTileMap || this.maps.baseMapRectBounds['min']['x'] === 0) {
317
- zoomLevel = calculateZoomLevel(minLat, maxLat, minLong, maxLong, mapWidth, mapHeight, this.maps, false);
318
- if (this.maps.isTileMap) {
319
- markerFactor = isNullOrUndefined(this.maps.markerZoomFactor) ?
320
- zoomLevel : isNullOrUndefined(this.maps.mapScaleValue) ?
321
- zoomLevel : this.maps.mapScaleValue > 1 && this.maps.markerZoomFactor !== 1 ?
322
- this.maps.mapScaleValue : zoomLevel;
323
- } else {
324
- markerFactor = isNullOrUndefined(this.maps.mapScaleValue) ? zoomLevel :
325
- (Math.floor(this.maps.scale) !== 1 &&
326
- this.maps.mapScaleValue !== zoomLevel)
327
- &&
328
- (isNullOrUndefined(this.maps.shouldZoomCurrentFactor))
329
- ? this.maps.mapScaleValue : zoomLevel;
330
- if (((markerFactor === this.maps.mapScaleValue &&
331
- (this.maps.markerZoomFactor === 1 || this.maps.mapScaleValue === 1))
332
- && (!this.maps.enablePersistence))) {
333
- markerFactor = zoomLevel;
334
- }
335
- }
336
- } else {
337
- zoomLevel = this.calculateIndividualLayerMarkerZoomLevel(mapWidth, mapHeight, maxZoomFact);
338
- markerFactor = isNullOrUndefined(this.maps.mapScaleValue) ? zoomLevel :
339
- (this.maps.mapScaleValue !== zoomLevel)
340
- ? this.maps.mapScaleValue : zoomLevel;
341
- }
342
- this.maps.markerZoomFactor = markerFactor;
343
- }
344
- } else {
345
- this.maps.markerZoomedState = false;
346
- if (this.maps.markerZoomFactor > 1) {
347
- this.maps.markerCenterLatitude = null;
348
- this.maps.markerCenterLongitude = null;
349
- this.maps.markerZoomFactor = 1;
350
- if (!this.maps.enablePersistence) {
351
- this.maps.mapScaleValue = 1;
352
- }
353
- }
354
- if (this.maps.isTileMap && !this.maps.enablePersistence
355
- && this.maps.mapScaleValue <= 1) {
356
- this.maps.tileZoomLevel = this.maps.mapScaleValue === 0 ? (this.maps.isZoomByPosition ? this.maps.tileZoomLevel : 1)
357
- : this.maps.mapScaleValue;
358
- if (this.maps.mapScaleValue === 1 && this.maps.markerZoomFactor === 1 &&
359
- !isNullOrUndefined(this.maps.tileTranslatePoint)) {
360
- this.maps.tileTranslatePoint.x = 0;
361
- this.maps.tileTranslatePoint.y = 0;
362
- }
363
- }
364
- }
365
- }
366
- }
367
- /**
368
- * To check and trigger marker click event.
369
- *
370
- * @param {PointerEvent} e - Specifies the pointer event argument.
371
- * @returns {void}
372
- * @private
373
- */
374
- public markerClick(e: PointerEvent): void {
375
- let target: string = (e.target as Element).id;
376
- if (target.indexOf(this.maps.element.id) === -1) {
377
- const ancestor: Element = (e.target as Element).closest('.' + this.maps.element.id + '_marker_template_element');
378
- if (!isNullOrUndefined(ancestor) && ancestor.id.indexOf('_MarkerIndex_') > -1) {
379
- target = ancestor.id;
380
- }
381
- }
382
- if (target.indexOf('_LayerIndex_') === -1 || target.indexOf('_cluster_') > 0) {
383
- return;
384
- }
385
- const options: { marker: MarkerSettingsModel, data: object } = this.getMarker(target);
386
- if (isNullOrUndefined(options)) {
387
- return;
388
- }
389
- if (options.marker.enableDrag){
390
- document.getElementById(this.maps.element.id + '_svg').style.cursor = 'grabbing';
391
- }
392
- const eventArgs: IMarkerClickEventArgs = {
393
- cancel: false, name: markerClick, data: options.data, maps: this.maps,
394
- marker: options.marker, target: target, x: e.clientX, y: e.clientY,
395
- latitude: options.data['latitude'] || options.data['Latitude'],
396
- longitude: options.data['longitude'] || options.data['Longitude'],
397
- value: options.data['name']
398
- };
399
- this.maps.trigger(markerClick, eventArgs);
400
- if (options.marker.enableDrag) {
401
- let isCluster: boolean = false;
402
- const layerIndex: number = parseInt(target.split('_LayerIndex_')[1].split('_')[0], 10);
403
- const markerIndex: number = parseInt(target.split('_MarkerIndex_')[1].split('_')[0], 10);
404
- const dataIndex: number = parseInt(target.split('_dataIndex_')[1].split('_')[0], 10);
405
- const marker: MarkerSettingsModel = this.maps.layers[layerIndex as number].markerSettings[markerIndex as number];
406
- if (this.sameMarkerData.length > 0) {
407
- isCluster = (this.sameMarkerData[0].data.filter((el : object) => { return ((el['index'] as number) === dataIndex); })).length > 0 &&
408
- this.sameMarkerData[0].layerIndex === layerIndex && this.sameMarkerData[0].markerIndex === markerIndex;
409
- }
410
- if (!isCluster) {
411
- const dragEventArgs: IMarkerDragEventArgs = {
412
- name: markerDragStart, x: e.clientX, y: e.clientY,
413
- latitude: options.data['latitude'] || options.data['Latitude'],
414
- longitude: options.data['longitude'] || options.data['Longitude'],
415
- layerIndex: layerIndex, markerIndex: markerIndex, dataIndex: dataIndex
416
- };
417
- this.maps.trigger(markerDragStart, dragEventArgs);
418
- this.maps.markerDragArgument = {
419
- targetId: target, x: e.clientX, y: e.clientY,
420
- latitude: options.data['latitude'] || options.data['Latitude'],
421
- longitude: options.data['longitude'] || options.data['Longitude'],
422
- shape: isNullOrUndefined(marker.shapeValuePath) ? marker.shape
423
- : marker.dataSource[dataIndex as number][marker.shapeValuePath],
424
- layerIndex: layerIndex, markerIndex: markerIndex, dataIndex: dataIndex
425
- };
426
- }
427
- }
428
- }
429
- /**
430
- * To check and trigger Cluster click event.
431
- *
432
- * @param {PointerEvent} e - Specifies the pointer event argument.
433
- * @returns {void}
434
- * @private
435
- */
436
- public markerClusterClick(e: PointerEvent): void {
437
- const target: string = (e.target as Element).id;
438
- if (target.indexOf('_LayerIndex_') === -1 || target.indexOf('_cluster_') === -1) {
439
- return;
440
- }
441
- const options: { marker: MarkerSettingsModel, data: object, clusterCollection: MarkerClusterData[],
442
- markCollection: object[] } = this.getMarker(target);
443
- if (isNullOrUndefined(options)) {
444
- return;
445
- }
446
- if ((options.clusterCollection.length > 0 && this.maps.markerClusterExpand)) {
447
- if (getElement(this.maps.element.id + '_mapsTooltip') &&
448
- this.maps.mapsTooltipModule.tooltipTargetID.indexOf('_MarkerIndex_') > -1) {
449
- removeElement(this.maps.element.id + '_mapsTooltip');
450
- }
451
- if (this.sameMarkerData.length > 0 && !this.maps.markerClusterExpandCheck) {
452
- this.maps.markerClusterExpandCheck = true;
453
- mergeSeparateCluster(this.sameMarkerData, this.maps);
454
- } else {
455
- this.sameMarkerData = options.clusterCollection;
456
- this.maps.markerClusterExpandCheck = false;
457
- clusterSeparate(this.sameMarkerData, this.maps, this.markerSVGObject, true);
458
- }
459
- }
460
- const eventArgs: IMarkerClusterClickEventArgs = {
461
- cancel: false, name: markerClusterClick, data: options, maps: this.maps,
462
- target: target, x: e.clientX, y: e.clientY,
463
- latitude: options.data['latitude'] || options.data['Latitude'], longitude: options.data['longitude'] || options.data['Longitude'],
464
- markerClusterCollection: options['markCollection']
465
- };
466
- this.maps.trigger(markerClusterClick, eventArgs);
467
- }
468
- /**
469
- * To get marker from target id.
470
- *
471
- * @param {string} target - Specifies the target
472
- * @returns {object} - Returns the marker, data, clusterCollection, markCollection
473
- */
474
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
475
- private getMarker(target: string): { marker: MarkerSettingsModel, data: any,
476
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
477
- clusterCollection: MarkerClusterData[], markCollection: any[] } {
478
- const id: string[] = target.split('_LayerIndex_');
479
- const index: number = parseInt(id[1].split('_')[0], 10);
480
- const layer: LayerSettings = <LayerSettings>this.maps.layers[index as number];
481
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
482
- let data: any;
483
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
484
- const markCollection: any[] = [];
485
- const clusterCollection: MarkerClusterData[] = [];
486
- let marker: MarkerSettingsModel;
487
- if (target.indexOf('_MarkerIndex_') > -1) {
488
- const markerIndex: number = parseInt(id[1].split('_MarkerIndex_')[1].split('_')[0], 10);
489
- const dataIndex: number = parseInt(id[1].split('_dataIndex_')[1].split('_')[0], 10);
490
- marker = layer.markerSettings[markerIndex as number];
491
- const allowInnerClusterSetting: boolean = this.allowInnerClusterSetting(layer);
492
- this.maps.markerClusterExpand = !allowInnerClusterSetting && layer.markerClusterSettings.allowClustering ?
493
- layer.markerClusterSettings.allowClusterExpand : marker.clusterSettings.allowClusterExpand;
494
- if (!isNaN(markerIndex)) {
495
- data = marker.dataSource[dataIndex as number];
496
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
497
- let collection: any[] = [];
498
- if (!marker.template && (target.indexOf('_cluster_') > -1) && this.maps.markerClusterExpand) {
499
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
500
- Array.prototype.forEach.call(marker.dataSource, (location: any, index: number) => {
501
- if (location['latitude'] === data['latitude'] && location['longitude'] === data['longitude']) {
502
- collection.push({ data: data, index: index });
503
- }
504
- });
505
- }
506
- if ((target.indexOf('_cluster_') > -1)) {
507
- let isClusterSame: boolean = false;
508
- const cluster: MarkerClusterSettingsModel = !allowInnerClusterSetting && layer.markerClusterSettings.allowClustering ?
509
- layer.markerClusterSettings : layer.markerSettings[markerIndex as number].clusterSettings;
510
- const clusterElement: HTMLElement = document.getElementById(target.indexOf('_datalabel_') > -1 ? cluster.shape === 'Balloon' ? target.split('_datalabel_')[0] + '_Group' : target.split('_datalabel_')[0] : cluster.shape === 'Balloon' ? target + '_Group' : target);
511
- const indexes: number[] = cluster.shape === 'Balloon' ? (clusterElement.children[0] as HTMLElement).textContent.split(',').map(Number) : (clusterElement as HTMLElement).textContent.split(',').map(Number);
512
- collection = [];
513
- for (const i of indexes) {
514
- collection.push({ data: marker.dataSource[i as number], index: i });
515
- markCollection.push(marker.dataSource[i as number]);
516
- }
517
- isClusterSame = false;
518
- clusterCollection.push(<MarkerClusterData>{
519
- data: collection, layerIndex: index, markerIndex: markerIndex, dataIndex: dataIndex,
520
- targetClusterIndex: +(target.split('_cluster_')[1].indexOf('_datalabel_') > -1 ? target.split('_cluster_')[1].split('_datalabel_')[0] : target.split('_cluster_')[1]),
521
- isClusterSame: isClusterSame
522
- });
523
- }
524
- return { marker: marker, data: data, clusterCollection: clusterCollection, markCollection: markCollection };
525
- }
526
- }
527
- return null;
528
- }
529
- /**
530
- * To check and trigger marker move event.
531
- *
532
- * @param {PointerEvent} e - Specifies the pointer event argument.
533
- * @returns {void}
534
- * @private
535
- */
536
- public markerMove(e: PointerEvent): void {
537
- const targetId: string = (e.target as Element).id;
538
- if (targetId.indexOf('_LayerIndex_') === -1 || targetId.indexOf('_cluster_') > 0) {
539
- return;
540
- }
541
- const options: { marker: MarkerSettingsModel, data: object } = this.getMarker(targetId);
542
- if (isNullOrUndefined(options)) {
543
- return;
544
- }
545
- if (options.marker.enableDrag){
546
- document.getElementById(this.maps.element.id + '_svg').style.cursor = isNullOrUndefined(this.maps.markerDragArgument) ?
547
- 'pointer' : 'grabbing';
548
- }
549
- const eventArgs: IMarkerMoveEventArgs = {
550
- cancel: false, name: markerMouseMove, data: options.data,
551
- maps: this.maps, target: targetId, x: e.clientX, y: e.clientY
552
- };
553
- this.maps.trigger(markerMouseMove, eventArgs);
554
- }
555
- /**
556
- * To check and trigger cluster move event.
557
- *
558
- * @param {PointerEvent} e - Specifies the pointer event argument.
559
- * @returns {void}
560
- * @private
561
- */
562
- public markerClusterMouseMove(e: PointerEvent): void {
563
- const targetId: string = (e.target as Element).id;
564
- if (targetId.indexOf('_LayerIndex_') === -1 || targetId.indexOf('_cluster_') === -1) {
565
- return;
566
- }
567
- const options: { marker: MarkerSettingsModel, data: object, clusterCollection: MarkerClusterData[] } = this.getMarker(targetId);
568
- if (this.maps.markerClusterExpand) {
569
- (e.target as HTMLElement).style.cursor = 'pointer';
570
- }
571
- if (isNullOrUndefined(options)) {
572
- return;
573
- }
574
- const eventArgs: IMarkerClusterMoveEventArgs = {
575
- cancel: false, name: markerClusterMouseMove, data: options.data, maps: this.maps,
576
- target: targetId, x: e.clientX, y: e.clientY
577
- };
578
- this.maps.trigger(markerClusterMouseMove, eventArgs);
579
- }
580
-
581
- /**
582
- * This method is used to return whether the clustering is enabled in any marker settings.
583
- *
584
- * @param {LayerSettings} layer - Specifies the layer settings
585
- * @returns {boolean} - Specifies whether the clustering is enabled in any marker settings.
586
- * @private
587
- */
588
- public allowInnerClusterSetting(layer: LayerSettings): boolean {
589
- let allowInnerClusterSetting: boolean = false;
590
- for (let markerIndex: number = 0; markerIndex < layer.markerSettings.length; markerIndex++) {
591
- if (layer.markerSettings[markerIndex as number].clusterSettings.allowClustering) {
592
- allowInnerClusterSetting = true;
593
- break;
594
- }
595
- }
596
- return allowInnerClusterSetting;
597
- }
598
-
599
- /**
600
- * @private
601
- * @returns {void}
602
- */
603
- public initializeMarkerClusterList(): void {
604
- for (let i: number = 0; i < this.maps.layers.length; i++) {
605
- this.initialMarkerCluster[i as number] = [];
606
- this.zoomedMarkerCluster[i as number] = [];
607
- }
608
- }
609
-
610
- /**
611
- * Get module name.
612
- *
613
- * @returns {string} - Returns the module name
614
- */
615
- protected getModuleName(): string {
616
- return 'Marker';
617
- }
618
-
619
- /**
620
- * To destroy the layers.
621
- *
622
- * @returns {void}
623
- * @private
624
- */
625
- public destroy(): void {
626
- this.maps = null;
627
- this.markerSVGObject = null;
628
- this.sameMarkerData = [];
629
- this.initialMarkerCluster = [];
630
- this.zoomedMarkerCluster = [];
631
- }
632
- }
@@ -1,33 +0,0 @@
1
- import { Maps } from '../../index';
2
- import { LayerSettings } from '../index';
3
- /**
4
- * navigation-selected-line
5
- */
6
- export declare class NavigationLine {
7
- private maps;
8
- constructor(maps: Maps);
9
- /**
10
- * To render navigation line for maps.
11
- *
12
- * @param {LayerSettings} layer - Specifies the layer instance to which the navigation line is to be rendered.
13
- * @param {number} factor - Specifies the current zoom factor of the Maps.
14
- * @param {number} layerIndex -Specifies the index of current layer.
15
- * @returns {Element} - Returns the navigation line element.
16
- * @private
17
- */
18
- renderNavigation(layer: LayerSettings, factor: number, layerIndex: number): Element;
19
- private convertRadius;
20
- /**
21
- * Get module name.
22
- *
23
- * @returns {string} - Returns the module name
24
- */
25
- protected getModuleName(): string;
26
- /**
27
- * To destroy the layers.
28
- *
29
- * @returns {void}
30
- * @private
31
- */
32
- destroy(): void;
33
- }