[英]Ionic 2 Segments not working with Google Maps
Im trying to implement Google Maps in ionic 2 as Segments (Map and List). 我试图将Ionic 2中的Google Maps实施为路段(地图和列表)。
Here is my HTML: 这是我的HTML:
<ion-header>
<ion-navbar>
<button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-segment [(ngModel)]="clients">
<ion-segment-button value="map">
Map
</ion-segment-button>
<ion-segment-button value="list">
List
</ion-segment-button>
</ion-segment>
</ion-navbar>
</ion-header>
<ion-content>
<div [ngSwitch]="clients">
<div *ngSwitchCase="'map'">
<div #map id="map"></div>
</div>
<ion-list *ngSwitchCase="'list'">
<ion-item>
<h2>List Item 1</h2>
</ion-item>
</ion-list>
</div>
</ion-content>
Here is my .scss file: 这是我的.scss文件:
#map {
width: 100%;
height: 100%;
}
When i load the App, List segment works fine but Maps appear as white screen. 当我加载应用程序时,列表段工作正常,但地图显示为白屏。 If i define maps div tag right after the ion-content tag, then maps are displayed in both segments. 如果我在离子含量标签后立即定义map div标签,则地图将显示在两个片段中。 How can i have Maps in 1 segment and List in other segment? 如何在1个细分中拥有地图,在另一个细分中拥有列表?
The div which contains the map has a height oh 0 px, so the map is not visible. 包含地图的div的高度为oh 0 px,因此该地图不可见。 Change your code to something like that: 将您的代码更改为类似的内容:
<div class="map-wrapper" [ngSwitch]="clients">
<div *ngSwitchCase="'map'" #map id="map"></div>
</div>
And then set the .map-wrapper class to a height of 100% in your CSS/SASS/LESS. 然后在CSS / SASS / LESS中将.map-wrapper类的高度设置为100%。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.