Ionic 2,在离子段中使用谷歌地图 [英] Ionic 2, use google maps in ion-segments

查看:93
本文介绍了Ionic 2,在离子段中使用谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题。 Google地图未显示在离子2细分中,但显示在细分之外。我使用以下代码,

I have a slight problem. Google maps is not showing in ionic 2 segments but showing outside of segments. I am using the following code,

 <div [ngSwitch]="report_details">
    <div *ngSwitchCase="'details'">
        <div #map id="map"></div>
    </div>
 </div>

我尝试了以下解决方案,但没有奏效:

I have tried the following solutions but did not work:


  1. 在外部div上使用100%的高度和宽度。

  2. 在地图加载功能上使用超时。


推荐答案

我遇到了同样的问题,谷歌地图完全展现在外部细分市场。因此,按照建议的方法通过biranchi125在离子论坛你可以将地图放在片段之外并处理何时用选择变量显示它,如下所示:

I had the same problem as you point out, Google Maps is showing perfectly outside segments. So following the approach suggested by biranchi125 in Ionic forum you can place the map outside the segments and handle when to show it whith the selection variable, like this:

<div [ngSwitch]="report_details">
  <div *ngSwitchCase="'details'">
    <!-- you can place other elements here if you want -->
  </div>
  <div [style.display]="report_details == 'details' ? 'block' : 'none'">
     <div #map id="map"></div>
  </div>
</div>

并且有效:)

这篇关于Ionic 2,在离子段中使用谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆