Google maps 离子2-<;离子段>&书信电报;部门>;谷歌地图不显示

Google maps 离子2-<;离子段>&书信电报;部门>;谷歌地图不显示,google-maps,ionic2,Google Maps,Ionic2,加载页面时会显示google地图。 但当切换离子段时,不会显示贴图。 下面是我的爱奥尼亚2代码: <ion-header> <ion-toolbar no-border-top> <ion-segment [(ngModel)]="social" (ionChange)="segementChangeAction()"> <ion-segment-button value="activity"> Map

加载页面时会显示google地图。 但当切换离子段时,不会显示贴图。 下面是我的爱奥尼亚2代码:

<ion-header>
  <ion-toolbar no-border-top>
    <ion-segment [(ngModel)]="social" (ionChange)="segementChangeAction()">
      <ion-segment-button value="activity">
        Map
      </ion-segment-button>
      <ion-segment-button value="messages">
        Messages
      </ion-segment-button>
    </ion-segment>
  </ion-toolbar>
</ion-header>



<ion-content no-bounce>
  <div [ngSwitch]="social">
    <div *ngSwitchCase="'activity'">
        <div #map id="map"></div>
    </div>
    <div *ngSwitchCase="'messages'">
      Some text.....        
    </div>
  </div>
</ion-content>

地图
信息
一些文字。。。。。

这是因为在切换ion段时,ngSwitchCase会从DOM中删除映射的div。这样做:

<div [ngSwitch]="social">
  <div [style.display]="social === 'activity' ? 'block' : 'none'">
    <div #map id="map"></div>
  </div>
  <div *ngSwitchCase="'messages'">
    Some text.....        
  </div>
</div>

一些文字。。。。。

为了让它在爱奥尼亚3中工作,我必须做一些调整,增加高度:容器100%:

<div [ngSwitch]="social">
  <div [style.display]="social === 'activity' ? 'block' : 'none'" style="height: 100%">
  <div #map id="map"></div>
</div>
<div *ngSwitchCase="'messages'">
  Some text.....        
</div>

一些文字。。。。。