@artstesh/maps 1.1.30 → 1.1.31

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.
@@ -2749,6 +2749,7 @@ class MapPlateComponent extends DestructibleComponent {
2749
2749
  this.mapFactory = mapFactory;
2750
2750
  this.registrator = registrator;
2751
2751
  this.detector = detector;
2752
+ this.renderTryCount = 0;
2752
2753
  this.osmUrl = '';
2753
2754
  this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
2754
2755
  this._settings = new MapSettings();
@@ -2763,7 +2764,7 @@ class MapPlateComponent extends DestructibleComponent {
2763
2764
  this._settings = value;
2764
2765
  this.setOsm();
2765
2766
  }
2766
- ngOnInit() {
2767
+ initializeMap() {
2767
2768
  useGeographic();
2768
2769
  this.map = this.mapFactory.build(this._settings);
2769
2770
  this.map.setTarget(this.elementRef.nativeElement);
@@ -2777,6 +2778,20 @@ class MapPlateComponent extends DestructibleComponent {
2777
2778
  });
2778
2779
  this.setOsm();
2779
2780
  }
2781
+ ngAfterViewInit() {
2782
+ const mapContainer = this.elementRef.nativeElement;
2783
+ const checkContainerSize = () => {
2784
+ const { clientWidth, clientHeight } = mapContainer;
2785
+ if (clientWidth > 0 && clientHeight > 0) {
2786
+ this.initializeMap();
2787
+ }
2788
+ else {
2789
+ console.error("Map's container is not rendered yet or has zero size. Trying again in 100 ms.");
2790
+ setTimeout(checkContainerSize, 20 * ++this.renderTryCount); // Проверка каждые 100 мс
2791
+ }
2792
+ };
2793
+ checkContainerSize();
2794
+ }
2780
2795
  setOsm() {
2781
2796
  if (!this.map)
2782
2797
  return;