Commit cc15b8282c670853fc32f8703db4de36cc8d5291

Authored by Igor Kulikov
Committed by GitHub
2 parents 80ea2b7d c94b4e1d

Merge pull request #3135 from vvlladd28/bugs/polygons

[3.0] Fix: resize polygons for image map
@@ -42,6 +42,7 @@ import { Polygon } from './polygon'; @@ -42,6 +42,7 @@ import { Polygon } from './polygon';
42 import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils'; 42 import { createTooltip, parseArray, safeExecute } from '@home/components/widget/lib/maps/maps-utils';
43 import { WidgetContext } from '@home/models/widget-component.models'; 43 import { WidgetContext } from '@home/models/widget-component.models';
44 import { DatasourceData } from '@shared/models/widget.models'; 44 import { DatasourceData } from '@shared/models/widget.models';
  45 +import { deepClone } from '@core/utils';
45 46
46 export default abstract class LeafletMap { 47 export default abstract class LeafletMap {
47 48
@@ -57,6 +58,7 @@ export default abstract class LeafletMap { @@ -57,6 +58,7 @@ export default abstract class LeafletMap {
57 markersCluster: MarkerClusterGroup; 58 markersCluster: MarkerClusterGroup;
58 points: FeatureGroup; 59 points: FeatureGroup;
59 markersData: FormattedData[] = []; 60 markersData: FormattedData[] = [];
  61 + polygonsData: FormattedData[] = [];
60 62
61 protected constructor(public ctx: WidgetContext, 63 protected constructor(public ctx: WidgetContext,
62 public $container: HTMLElement, 64 public $container: HTMLElement,
@@ -480,6 +482,7 @@ export default abstract class LeafletMap { @@ -480,6 +482,7 @@ export default abstract class LeafletMap {
480 482
481 updatePolygons(polyData: FormattedData[], updateBounds = true) { 483 updatePolygons(polyData: FormattedData[], updateBounds = true) {
482 const keys: string[] = []; 484 const keys: string[] = [];
  485 + this.polygonsData = deepClone(polyData);
483 polyData.forEach((data: FormattedData) => { 486 polyData.forEach((data: FormattedData) => {
484 if (data && data.hasOwnProperty(this.options.polygonKeyName) && data[this.options.polygonKeyName] !== null) { 487 if (data && data.hasOwnProperty(this.options.polygonKeyName) && data[this.options.polygonKeyName] !== null) {
485 if (typeof (data[this.options.polygonKeyName]) === 'string') { 488 if (typeof (data[this.options.polygonKeyName]) === 'string') {
@@ -184,6 +184,7 @@ export class ImageMap extends LeafletMap { @@ -184,6 +184,7 @@ export class ImageMap extends LeafletMap {
184 this.updateBounds(updateImage, lastCenterPos); 184 this.updateBounds(updateImage, lastCenterPos);
185 this.map.invalidateSize(true); 185 this.map.invalidateSize(true);
186 this.updateMarkers(this.markersData); 186 this.updateMarkers(this.markersData);
  187 + this.updatePolygons(this.polygonsData);
187 } 188 }
188 } 189 }
189 } 190 }