简体   繁体   English

ionic3 Google地图未显示在导航堆栈中

[英]ionic3 google map not showing in navstack

I can't show google map in ionic 3 application when using tabs with link. 使用带有链接的标签时,无法在Ionic 3应用程序中显示Google Map。

i got 3tabs and in 1 tab i have a link too google map for users. 我得到了3tabs,在1个选项卡中我也有一个链接google map for users。

lets assume my current tab name is AddressPage , when i click on link to show google map , i will go to MapPage with nav.push() and my ion-header loads but i cant see google map in middle of screen and it shows my previous page AddressPage content in middle of map page. 让我们假设我当前的标签名是AddressPage ,当我单击链接以显示google map时,我将使用nav.push()转到MapPage ,并且加载了我的离子头,但我在屏幕中间看不到google map,它显示了我的地图页面中间的上一页AddressPage内容。

i'm sure i have google map in there because i have a button in ion content that shows the current lat\\lng of the marker and it works , but the map is not there. 我确定我在其中有google地图,因为我在离子含量中有一个按钮,可以显示标记的当前纬度并且可以使用,但是该地图不存在。

i used safari to debug the application and when i make all ion-app visibility to none , google map is showing. 我使用了Safari来调试应用程序,当我将所有ion-app可见性设置为none时,显示了谷歌地图。 so i think its some css problem with ionic and google map sdk. 所以我认为它与ionic和google map sdk有关的一些CSS问题。

BTW i can show map when i'm not using tabs and its my home page , so i only have this problem in this situation. 顺便说一句,当我不使用选项卡及其主页时,我可以显示地图,因此在这种情况下我只会遇到此问题。

Can any1 help me for this? 有人可以帮我吗? i searched a lot in stackoverflow and ionic forum and i almost did everything i saw on the internet. 我在stackoverflow和ionic论坛中搜索了很多内容,几乎完成了我在互联网上看到的所有事情。 from adding css like adding nav-decorator css to hide or .... 从添加css就像添加nav-decorator css来隐藏或...。

Thank in advance for any help ! 在此先感谢您的帮助!

its my ionic info : 它是我的离子信息:

ionic (Ionic CLI)  : 4.1.2 (C:\Users\ASUS\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework    : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0

 ionViewDidLoad() {
    this.isEdit = this.navParams.get('isEdit');
    this.loadMap();
}

this is my map page.ts code 这是我的地图page.ts代码

ionViewDidLoad() {
    this.isEdit = this.navParams.get('isEdit');
    this.loadMap();
}

//load the map
loadMap() {
    //google map options
    let mapOptions: GoogleMapOptions = {
        camera: {
            target: this.mapCenter,
            zoom: 16,
            tilt: 10,
        },
        mapTypeId: 'ROADMAP',
        controls: {
            myLocationButton: true,
            zoom: false
        },
    };
    this.map = GoogleMaps.create('map_canvas', mapOptions);
    this.showLoading(null);
    this.map.on(GoogleMapsEvent.MAP_READY)
        .subscribe((resp) => {
            this.hideLoading();

        });

}

this is my map page css 这是我的地图页面的CSS

 #map_canvas {
height: 100%;
width: 100%;
  }

this is my map.html 这是我的map.html

<ion-header>
<ion-navbar>
    <ion-title text-center>
        انتخاب آدرس
    </ion-title>
</ion-navbar>
</ion-header>
 <ion-content>

<div id="map_canvas" >

</div>

</ion-content>

When you work with tabs , this solution works for you to visible and hide google map between different tabs. 当你与标签的工作,该解决方案适用于您不同的选项卡之间的可见和隐藏谷歌地图。

initialMapLoad: boolean = true;

ngAfterViewInit(){
  this.loadMap();
}

ionViewWillEnter(){
  if (!this.initialMapLoad) {
    // reset div & *then* set visibility to smooth out reloading of map
    this.map.setDiv('map_canvas');
    this.map.setVisible(true);
  } else {
    this.initialMapLoad = false;
  }
}

ionViewWillLeave() {
  // unset div & visibility on exit
  this.map.setVisible(false);
  this.map.setDiv(null);
}

Other than this you can use Google maps Javascript API. 除此之外,您还可以使用Google Maps Javascript API。 It works very well everywhere. 它到处都很好。

If still, you have any issue, please feel free to comment . 如果仍然有任何问题, 请随时发表评论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM