I had same problem and I solved by using <ion-toolbar>
instead of <ion-navbar>
page.html
<ion-header>
<ion-toolbar>
<ion-buttons left>
<button ion-button icon-only (click)="toggleMenu()">
<ion-icon name="menu"></ion-icon>
</button>
</ion-buttons>
<ion-title>Page Two</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<div #map id="map"></div>
</ion-content>
page.ts
toggleMenu() {
this.menuCtrl.toggle().then(() => {
if(this.menuCtrl.isOpen()) {
this.map.setClickable(false);
} else {
this.map.setClickable(true);
}
});
}
toogleMenu() function is fired when menu button is clicked.
From there, I can check whether the menu is toggled and setClickable() [true/false]
I think this is the quickest way.
Hi, I had same problem with google map and sidemenu.
I added menuType=âpushâ and it work fine for me.
The problem is with menuType=âoverlayâ used for android.
details https://ionicframework.com/docs/v2/api/components/menu/Menu/
other solution:
In google map page:
map: GoogleMap;
...
...
constructor(public menuController: MenuController, public platform: Platform) {
let leftMenu = menuController.get('left');
if (leftMenu) {
leftMenu.ionOpen.subscribe(() => {
if (this.map) {
this.map.setClickable(false);
}
});
leftMenu.ionClose.subscribe(() => {
if (this.map) {
this.map.setClickable(true);
}
});
}
}
Regards
Hello,
I tried using your solution but it does not work. When I click on side menu it throws the error as MyApp.html:1 ERROR TypeError: Cannot read property âsetClickableâ of undefined.
Please help!
Thank You.
I am new to Ionic 2 and also to services. What is the exact structure of your map service?
I do not know how to use the code you provided to me;its giving me errors!
Thank You
Please post your code as well as the errors youâre getting.
I created a service for map-service like:
map-service.ts
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import {GoogleMaps} from '@ionic-native/google-maps';
@Injectable()
export class MapService {
constructor(public http: Http,public googleMaps:GoogleMaps) {
console.log('Hello MapService Provider');
}
}
Now in this block of code where am I suppose to include your solution?
Thank You
Hi Markus, sorry for the late reply, I was away for a while.
Iâm not quite sure where youâre stuck. For my solution, you would put the code snippet marked as âin the map providerâ just below your constructor in your provider (make sure to set the âsettingsâ accordingly, most importantly to specify the container element for the map).
Youâll also need the other two code snippets Iâve posted in your app.component.ts and your map page