@artstesh/maps 4.1.31 → 4.1.32

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.
@@ -2718,6 +2718,7 @@ class MapPlateComponent extends DestructibleComponent {
2718
2718
  this.mapFactory = mapFactory;
2719
2719
  this.registrator = registrator;
2720
2720
  this.detector = detector;
2721
+ this.renderTryCount = 0;
2721
2722
  this.osmUrl = '';
2722
2723
  this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
2723
2724
  this._settings = new MapSettings();
@@ -2732,7 +2733,7 @@ class MapPlateComponent extends DestructibleComponent {
2732
2733
  this._settings = value;
2733
2734
  this.setOsm();
2734
2735
  }
2735
- ngOnInit() {
2736
+ initializeMap() {
2736
2737
  useGeographic();
2737
2738
  this.map = this.mapFactory.build(this._settings);
2738
2739
  this.map.setTarget(this.elementRef.nativeElement);
@@ -2746,6 +2747,20 @@ class MapPlateComponent extends DestructibleComponent {
2746
2747
  });
2747
2748
  this.setOsm();
2748
2749
  }
2750
+ ngAfterViewInit() {
2751
+ const mapContainer = this.elementRef.nativeElement;
2752
+ const checkContainerSize = () => {
2753
+ const { clientWidth, clientHeight } = mapContainer;
2754
+ if (clientWidth > 0 && clientHeight > 0) {
2755
+ this.initializeMap();
2756
+ }
2757
+ else {
2758
+ console.error("Map's container is not rendered yet or has zero size. Trying again in 100 ms.");
2759
+ setTimeout(checkContainerSize, 20 * ++this.renderTryCount); // Проверка каждые 100 мс
2760
+ }
2761
+ };
2762
+ checkContainerSize();
2763
+ }
2749
2764
  setOsm() {
2750
2765
  if (!this.map)
2751
2766
  return;