@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.
@@ -2698,6 +2698,7 @@ class MapPlateComponent extends DestructibleComponent {
2698
2698
  this.mapFactory = mapFactory;
2699
2699
  this.registrator = registrator;
2700
2700
  this.detector = detector;
2701
+ this.renderTryCount = 0;
2701
2702
  this.osmUrl = '';
2702
2703
  this.drawingLayerSettings = new FeatureLayerSettings().setName(MapConstants.DrawingLayerId);
2703
2704
  this._settings = new MapSettings();
@@ -2712,7 +2713,7 @@ class MapPlateComponent extends DestructibleComponent {
2712
2713
  this._settings = value;
2713
2714
  this.setOsm();
2714
2715
  }
2715
- ngOnInit() {
2716
+ initializeMap() {
2716
2717
  useGeographic();
2717
2718
  this.map = this.mapFactory.build(this._settings);
2718
2719
  this.map.setTarget(this.elementRef.nativeElement);
@@ -2726,6 +2727,20 @@ class MapPlateComponent extends DestructibleComponent {
2726
2727
  });
2727
2728
  this.setOsm();
2728
2729
  }
2730
+ ngAfterViewInit() {
2731
+ const mapContainer = this.elementRef.nativeElement;
2732
+ const checkContainerSize = () => {
2733
+ const { clientWidth, clientHeight } = mapContainer;
2734
+ if (clientWidth > 0 && clientHeight > 0) {
2735
+ this.initializeMap();
2736
+ }
2737
+ else {
2738
+ console.error("Map's container is not rendered yet or has zero size. Trying again in 100 ms.");
2739
+ setTimeout(checkContainerSize, 20 * ++this.renderTryCount); // Проверка каждые 100 мс
2740
+ }
2741
+ };
2742
+ checkContainerSize();
2743
+ }
2729
2744
  setOsm() {
2730
2745
  if (!this.map)
2731
2746
  return;