@syncfusion/ej2-maps 20.3.47 → 20.3.56

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.
@@ -1,4 +1,4 @@
1
- import { itemHighlight } from '../index';
1
+ import { itemHighlight, shapeHighlight } from '../index';
2
2
  import { Browser, isNullOrUndefined } from '@syncfusion/ej2-base';
3
3
  import { getElementsByClassName, getElement, removeClass, createStyle, customizeStyle, getTargetElement } from '../utils/helper';
4
4
  /**
@@ -158,16 +158,34 @@ var Highlight = /** @class */ (function () {
158
158
  var marker = parseInt(targetEle.id.split('_MarkerIndex_')[1].split('_')[0], 10);
159
159
  isMarkerSelect = this.maps.layers[layerIndex].markerSettings[marker].highlightSettings.enable;
160
160
  }
161
- var border = {
162
- color: (targetEle.parentElement.id.indexOf('LineString') === -1) ? this.highlightSettings.border.color : (this.highlightSettings.fill || this.highlightSettings.border.color),
163
- width: (targetEle.parentElement.id.indexOf('LineString') === -1) ? (this.highlightSettings.border.width / (isMarkerSelect ? 1 : this.maps.scale)) : (this.highlightSettings.border.width / this.maps.scale),
164
- opacity: this.highlightSettings.border.opacity
165
- };
161
+ var borderColor = (targetEle.parentElement.id.indexOf('LineString') === -1) ? this.highlightSettings.border.color : (this.highlightSettings.fill || this.highlightSettings.border.color);
162
+ var borderWidth = (targetEle.parentElement.id.indexOf('LineString') === -1) ? (this.highlightSettings.border.width / (isMarkerSelect ? 1 : this.maps.scale)) : (this.highlightSettings.border.width / this.maps.scale);
163
+ var borderOpacity = isNullOrUndefined(this.highlightSettings.border.opacity) ? this.highlightSettings.opacity : this.highlightSettings.border.opacity;
166
164
  var eventArgs = {
167
165
  opacity: this.highlightSettings.opacity,
168
166
  fill: (targetEle.parentElement.id.indexOf('LineString') === -1) ? (targetEle.id.indexOf('NavigationIndex') === -1 ? !isNullOrUndefined(this.highlightSettings.fill)
169
167
  ? this.highlightSettings.fill : targetEle.getAttribute('fill') : 'none') : 'transparent',
170
- border: border,
168
+ border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
169
+ cancel: false
170
+ };
171
+ var shapeEventArgs = {
172
+ opacity: eventArgs.opacity,
173
+ fill: eventArgs.fill,
174
+ border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
175
+ name: shapeHighlight,
176
+ target: targetEle.id,
177
+ cancel: false,
178
+ shapeData: shapeData,
179
+ data: data,
180
+ maps: this.maps
181
+ };
182
+ if (targetEle.id.indexOf('shapeIndex') > -1) {
183
+ this.maps.trigger(shapeHighlight, shapeEventArgs, function () { });
184
+ }
185
+ var itemEventArgs = {
186
+ opacity: eventArgs.opacity,
187
+ fill: eventArgs.fill,
188
+ border: { color: borderColor, width: borderWidth, opacity: borderOpacity },
171
189
  name: itemHighlight,
172
190
  target: targetEle.id,
173
191
  cancel: false,
@@ -175,15 +193,20 @@ var Highlight = /** @class */ (function () {
175
193
  data: data,
176
194
  maps: this.maps
177
195
  };
178
- this.maps.trigger(itemHighlight, eventArgs, function () {
179
- eventArgs.border.opacity = isNullOrUndefined(_this.highlightSettings.border.opacity) ? _this.highlightSettings.opacity : _this.highlightSettings.border.opacity;
180
- _this.highlightMap(targetEle, eventArgs);
196
+ this.maps.trigger(itemHighlight, itemEventArgs, function () {
197
+ itemEventArgs.cancel = eventArgs.cancel !== itemEventArgs.cancel ? itemEventArgs.cancel : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.cancel : eventArgs.cancel;
198
+ itemEventArgs.fill = eventArgs.fill !== itemEventArgs.fill ? itemEventArgs.fill : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.fill : eventArgs.fill;
199
+ itemEventArgs.opacity = eventArgs.opacity !== itemEventArgs.opacity ? itemEventArgs.opacity : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.opacity : eventArgs.opacity;
200
+ itemEventArgs.border.color = eventArgs.border.color !== itemEventArgs.border.color ? itemEventArgs.border.color : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.color : eventArgs.border.color;
201
+ itemEventArgs.border.width = eventArgs.border.width !== itemEventArgs.border.width ? itemEventArgs.border.width : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.width : eventArgs.border.width;
202
+ itemEventArgs.border.opacity = eventArgs.border.opacity !== itemEventArgs.border.opacity ? itemEventArgs.border.opacity : targetEle.id.indexOf('shapeIndex') > -1 ? shapeEventArgs.border.opacity : eventArgs.border.opacity;
203
+ _this.highlightMap(targetEle, itemEventArgs);
181
204
  });
182
205
  };
183
206
  Highlight.prototype.highlightMap = function (targetEle, eventArgs) {
184
207
  var parentElement;
185
208
  var children;
186
- if (targetEle.getAttribute('class') === 'highlightMapStyle') {
209
+ if (targetEle.getAttribute('class') === 'highlightMapStyle' || eventArgs.cancel) {
187
210
  return;
188
211
  }
189
212
  else {
@@ -161,9 +161,9 @@ var MapsTooltip = /** @class */ (function () {
161
161
  else {
162
162
  tooltipEle = createElement('div', {
163
163
  id: this.maps.element.id + '_mapsTooltip',
164
- className: 'EJ2-maps-Tooltip',
165
- styles: 'position: absolute;pointer-events:none;'
164
+ className: 'EJ2-maps-Tooltip'
166
165
  });
166
+ tooltipEle.style.cssText = 'position: absolute;pointer-events:none;';
167
167
  document.getElementById(this.maps.element.id + '_Secondary_Element').appendChild(tooltipEle);
168
168
  }
169
169
  if (option.template !== null && Object.keys(typeof option.template === 'object' ? option.template : {}).length === 1) {
@@ -241,7 +241,7 @@ var MapsTooltip = /** @class */ (function () {
241
241
  && tooltipTemplateElement.innerHTML.indexOf('</a>') !== -1) {
242
242
  var templateStyle = tooltipTemplateElement.getAttribute('style');
243
243
  templateStyle = templateStyle.replace('pointer-events: none;', 'position-events:all;');
244
- tooltipTemplateElement.setAttribute('style', templateStyle);
244
+ tooltipTemplateElement.style.cssText = templateStyle;
245
245
  }
246
246
  }
247
247
  else {
@@ -455,7 +455,7 @@ var Zoom = /** @class */ (function () {
455
455
  }
456
456
  else {
457
457
  markerStyle = 'visibility:hidden';
458
- currentEle.setAttribute('style', markerStyle);
458
+ currentEle.style.cssText = markerStyle;
459
459
  }
460
460
  }
461
461
  }
@@ -573,22 +573,22 @@ var Zoom = /** @class */ (function () {
573
573
  var layerIndex = parseInt((element ? element : layerElement).id.split('_LayerIndex_')[1].split('_')[0], 10);
574
574
  var markerSVGObject = this.maps.renderer.createGroup({
575
575
  id: this.maps.element.id + '_Markers_Group',
576
- class: 'GroupElement',
577
- style: 'pointer-events: auto;'
576
+ class: 'GroupElement'
578
577
  });
578
+ markerSVGObject.style.pointerEvents = 'auto';
579
579
  if (document.getElementById(markerSVGObject.id)) {
580
580
  removeElement(markerSVGObject.id);
581
581
  }
582
582
  var mapsAreaRect = this.maps.mapAreaRect;
583
583
  var markerTemplateElements = createElement('div', {
584
584
  id: this.maps.element.id + '_LayerIndex_' + layerIndex + '_Markers_Template_Group',
585
- className: 'template',
586
- styles: 'overflow: hidden; position: absolute;pointer-events: none;' +
587
- 'top:' + mapsAreaRect.y + 'px;' +
588
- 'left:' + mapsAreaRect.x + 'px;' +
589
- 'height:' + mapsAreaRect.height + 'px;' +
590
- 'width:' + mapsAreaRect.width + 'px;'
585
+ className: 'template'
591
586
  });
587
+ markerTemplateElements.style.cssText = 'overflow: hidden; position: absolute;pointer-events: none;' +
588
+ 'top:' + mapsAreaRect.y + 'px;' +
589
+ 'left:' + mapsAreaRect.x + 'px;' +
590
+ 'height:' + mapsAreaRect.height + 'px;' +
591
+ 'width:' + mapsAreaRect.width + 'px;';
592
592
  if (document.getElementById(markerTemplateElements.id)) {
593
593
  removeElement(markerTemplateElements.id);
594
594
  }
@@ -720,16 +720,26 @@ var Zoom = /** @class */ (function () {
720
720
  var labelX = label['location']['x'];
721
721
  var labelY = label['location']['y'];
722
722
  if (type === 'Template') {
723
- var layerEle = getElementByID(this.maps.element.id + '_Layer_Collections');
724
- labelX = ((Math.abs(this.maps.baseMapRectBounds['min']['x'] - labelX)) * scale);
725
- labelY = ((Math.abs(this.maps.baseMapRectBounds['min']['y'] - labelY)) * scale);
726
- var templateOffset = element.getBoundingClientRect();
727
- var layerOffset = layerEle.getBoundingClientRect();
728
- var elementOffset = element.parentElement.getBoundingClientRect();
729
- var x_3 = ((labelX) + (layerOffset.left - elementOffset.left) - (templateOffset.width / 2));
730
- var y_2 = ((labelY) + (layerOffset.top - elementOffset.top) - (templateOffset.height / 2));
731
- element.style.left = x_3 + 'px';
732
- element.style.top = y_2 + 'px';
723
+ var locationX = 0;
724
+ var locationY = 0;
725
+ if (this.maps.isTileMap) {
726
+ zoomtext = label['dataLabelText'];
727
+ zoomtextSize = measureText(zoomtext, style);
728
+ locationX = ((labelX + x) * scale) - (zoomtextSize['width'] / 2);
729
+ locationY = ((labelY + y) * scale) - (zoomtextSize['height']);
730
+ }
731
+ else {
732
+ var layerEle = getElementByID(this.maps.element.id + '_Layer_Collections');
733
+ labelX = ((Math.abs(this.maps.baseMapRectBounds['min']['x'] - labelX)) * scale);
734
+ labelY = ((Math.abs(this.maps.baseMapRectBounds['min']['y'] - labelY)) * scale);
735
+ var templateOffset = element.getBoundingClientRect();
736
+ var layerOffset = layerEle.getBoundingClientRect();
737
+ var elementOffset = element.parentElement.getBoundingClientRect();
738
+ locationX = ((labelX) + (layerOffset.left - elementOffset.left));
739
+ locationY = ((labelY) + (layerOffset.top - elementOffset.top));
740
+ }
741
+ element.style.left = locationX + 'px';
742
+ element.style.top = locationY + 'px';
733
743
  }
734
744
  else {
735
745
  labelX = ((labelX + x) * scale);
@@ -861,10 +871,10 @@ var Zoom = /** @class */ (function () {
861
871
  if (element['style']['display'] !== 'none') {
862
872
  if ((staticMapOffset['x'] > templateOffset['x'] || staticMapOffset['x'] + staticMapOffsetWidth < templateOffset['x'] + templateOffset['width'])
863
873
  && (staticMapOffset['y'] > templateOffset['y'] || staticMapOffset['y'] + staticMapOffset['height'] < templateOffset['y'] + templateOffset['height'])) {
864
- element['style']['display'] = 'none';
874
+ element.style.display = 'none';
865
875
  }
866
876
  else if ((staticMapOffset['x'] > templateOffset['x'] || staticMapOffset['x'] + staticMapOffsetWidth < templateOffset['x'] + templateOffset['width'])) {
867
- element['style']['display'] = 'none';
877
+ element.style.display = 'none';
868
878
  }
869
879
  }
870
880
  }
@@ -1001,7 +1011,6 @@ var Zoom = /** @class */ (function () {
1001
1011
  }
1002
1012
  map.zoomTranslatePoint = map.translatePoint;
1003
1013
  this.mouseDownPoints = this.mouseMovePoints;
1004
- this.maps.zoomNotApplied = false;
1005
1014
  this.isSingleClick = false;
1006
1015
  };
1007
1016
  Zoom.prototype.toAlignSublayer = function () {
@@ -1352,7 +1361,8 @@ var Zoom = /** @class */ (function () {
1352
1361
  Zoom.prototype.alignToolBar = function () {
1353
1362
  var map = this.maps;
1354
1363
  var padding = 10;
1355
- var element = createElement('div', { id: map.element.id + '_ToolBar', styles: 'position:absolute;z-index:2' });
1364
+ var element = createElement('div', { id: map.element.id + '_ToolBar' });
1365
+ element.style.cssText = 'position:absolute;z-index:2';
1356
1366
  var rectSVGObject = map.renderer.createSvg({
1357
1367
  id: map.element.id + '_Zooming_ToolBar', width: 10, height: 10
1358
1368
  });
@@ -684,9 +684,9 @@ export function renderTextElement(option, style, color, parent, isMinus) {
684
684
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
685
685
  export function convertElement(element, markerId, data, index, mapObj) {
686
686
  var childElement = createElement('div', {
687
- id: markerId,
688
- styles: 'position: absolute;pointer-events: auto;'
687
+ id: markerId
689
688
  });
689
+ childElement.style.cssText = 'position: absolute;pointer-events: auto;';
690
690
  var elementLength = element.length;
691
691
  while (elementLength > 0) {
692
692
  childElement.appendChild(element[0]);
@@ -773,11 +773,12 @@ export function convertElementFromLabel(element, labelId, data, index, mapObj) {
773
773
  // eslint-disable-next-line @typescript-eslint/ban-types
774
774
  templateHtml = templateHtml.replace(new RegExp('{{:' + properties[i] + '}}', 'g'), data[properties[i].toString()]);
775
775
  }
776
- return createElement('div', {
776
+ var templateEle = createElement('div', {
777
777
  id: labelId,
778
- innerHTML: templateHtml,
779
- styles: 'position: absolute'
778
+ innerHTML: templateHtml
780
779
  });
780
+ templateEle.style.position = 'absolute';
781
+ return templateEle;
781
782
  }
782
783
  /**
783
784
  *
@@ -1709,7 +1710,7 @@ export function checkShapeDataFields(dataSource, properties, dataPath, propertyP
1709
1710
  dataSource[i][dataPath]);
1710
1711
  var shapePath = checkPropertyPath(shapeDataPath, propertyPath, properties);
1711
1712
  var shapeDataPathValue = !isNullOrUndefined(shapeDataPath) && isNaN(properties[shapePath])
1712
- ? shapeDataPath.toLowerCase() : shapeDataPath;
1713
+ ? (typeof shapeDataPath === 'string' ? shapeDataPath.toLowerCase() : shapeDataPath) : shapeDataPath;
1713
1714
  var propertiesShapePathValue = !isNullOrUndefined(properties[shapePath]) && isNaN(properties[shapePath])
1714
1715
  ? properties[shapePath].toLowerCase() : properties[shapePath];
1715
1716
  if (shapeDataPathValue === propertiesShapePathValue) {
@@ -1734,7 +1735,8 @@ export function checkPropertyPath(shapeData, shapePropertyPath, shape) {
1734
1735
  var properties = (Object.prototype.toString.call(shapePropertyPath) === '[object Array]' ?
1735
1736
  shapePropertyPath : [shapePropertyPath]);
1736
1737
  for (var i = 0; i < properties.length; i++) {
1737
- var shapeDataValue = !isNullOrUndefined(shapeData) ? shapeData.toLowerCase() : shapeData;
1738
+ var shapeDataValue = !isNullOrUndefined(shapeData) && typeof shapeData === 'string' ?
1739
+ shapeData.toLowerCase() : shapeData;
1738
1740
  var shapePropertiesValue = !isNullOrUndefined(shape[properties[i]])
1739
1741
  && isNaN(shape[properties[i]])
1740
1742
  ? shape[properties[i]].toLowerCase() : shape[properties[i]];
@@ -2179,7 +2181,7 @@ export function getZoomTranslate(mapObject, layer, animate) {
2179
2181
  mapObject.zoomSettings.zoomFactor ===
2180
2182
  mapObject.mapScaleValue ? mapObject.zoomSettings.zoomFactor :
2181
2183
  mapObject.zoomSettings.zoomFactor !== mapObject.mapScaleValue && !mapObject.centerPositionChanged ? mapObject.mapScaleValue : mapObject.zoomSettings.zoomFactor;
2182
- if (mapObject.zoomSettings.shouldZoomInitially) {
2184
+ if (mapObject.zoomSettings.shouldZoomInitially && !mapObject.isZoomByPosition) {
2183
2185
  mapObject.mapScaleValue = zoomFactorValue = scaleFactor = ((mapObject.enablePersistence || mapObject.zoomSettings.shouldZoomInitially) && mapObject.scale === 1)
2184
2186
  ? mapObject.scale : (isNullOrUndefined(mapObject.markerZoomFactor)) ? mapObject.mapScaleValue : mapObject.markerZoomFactor;
2185
2187
  zoomFactorValue = mapObject.mapScaleValue;
@@ -2213,6 +2215,10 @@ export function getZoomTranslate(mapObject, layer, animate) {
2213
2215
  y = -point.y + topPosition;
2214
2216
  }
2215
2217
  else {
2218
+ if (mapObject.isZoomByPosition) {
2219
+ mapObject.zoomTranslatePoint.x = -point.x + leftPosition;
2220
+ mapObject.zoomTranslatePoint.y = -point.y + topPosition;
2221
+ }
2216
2222
  x = mapObject.zoomTranslatePoint.x;
2217
2223
  y = mapObject.zoomTranslatePoint.y;
2218
2224
  zoomFactorValue = zoomFactor;
@@ -2421,7 +2427,7 @@ export function triggerShapeEvent(targetId, selection, maps, eventName) {
2421
2427
  target: targetId,
2422
2428
  maps: maps
2423
2429
  };
2424
- maps.trigger(eventName, eventArgs, function (observedArgs) {
2430
+ maps.trigger(eventName, eventArgs, function () {
2425
2431
  eventArgs.border.opacity = isNullOrUndefined(eventArgs.border.opacity) ? eventArgs.opacity : eventArgs.border.opacity;
2426
2432
  });
2427
2433
  return eventArgs;
@@ -2650,11 +2656,11 @@ export function showTooltip(text, size, x, y, areaWidth, areaHeight, id, element
2650
2656
  }
2651
2657
  if (!tooltip) {
2652
2658
  tooltip = createElement('div', {
2653
- id: id,
2654
- styles: 'background-color: rgb(255, 255, 255) !important; color:black !important; ' +
2655
- 'position:absolute;border:1px solid rgb(0, 0, 0); padding-left:5px;' +
2656
- 'font-size:12px; font-family: "Segoe UI"; text-align:center'
2659
+ id: id
2657
2660
  });
2661
+ tooltip.style.cssText = 'background-color: rgb(255, 255, 255) !important; color:black !important; ' +
2662
+ 'position:absolute;border:1px solid rgb(0, 0, 0); padding-left:5px;' +
2663
+ 'font-size:12px; font-family: "Segoe UI"; text-align:center';
2658
2664
  }
2659
2665
  if (x < (areaWidth - width)) {
2660
2666
  // eslint-disable-next-line no-self-assign
@@ -2752,13 +2758,14 @@ export function createTooltip(id, text, top, left, fontSize) {
2752
2758
  'position:absolute;border:1px solid #707070;font-size:' + fontSize + ';border-radius:2px;';
2753
2759
  if (!tooltip) {
2754
2760
  tooltip = createElement('div', {
2755
- id: id, innerHTML: '&nbsp;' + text + '&nbsp;', styles: style
2761
+ id: id, innerHTML: '&nbsp;' + text + '&nbsp;'
2756
2762
  });
2763
+ tooltip.style.cssText = style;
2757
2764
  document.body.appendChild(tooltip);
2758
2765
  }
2759
2766
  else {
2760
- tooltip.setAttribute('innerHTML', '&nbsp;' + text + '&nbsp;');
2761
- tooltip.setAttribute('styles', style);
2767
+ tooltip.innerHTML = '&nbsp;' + text + '&nbsp;';
2768
+ tooltip.style.cssText = style;
2762
2769
  }
2763
2770
  }
2764
2771
  /**
@@ -3156,7 +3163,7 @@ export function animate(element, delay, duration, process, end) {
3156
3163
  end.call(_this, { element: element });
3157
3164
  if (element.id.indexOf('Marker') > -1) {
3158
3165
  var markerElement = getElementByID(element.id.split('_Layer')[0] + '_Markers_Group');
3159
- markerElement.setAttribute('style', markerStyle);
3166
+ markerElement.style.cssText = markerStyle;
3160
3167
  }
3161
3168
  }
3162
3169
  };