Google Map (cordova-plugin-googlemaps) Overlapping on Side_menu
Hello Everyone,
I am using cordova-plugin-googlemaps with ionic side menu. Map loading and working fine , Side Menu also opens fine but when i click on item in menus, that click hit on google map (zoom in) instead of navigate to menu items. Map page is overlapping on Side Menu.
I also Tried with map.setClickable(true|false); but nothing happens
Here is My Code
` import { Component } from '@angular/core'; import {Nav , Platform} from 'ionic-angular'; import {GoogleMap, GoogleMapsEvent, GoogleMapsLatLng} from 'ionic-native';
@Component({ templateUrl: 'hello-ionic.html' }) export class HelloIonicPage { map: GoogleMap; constructor(public nav:Nav,private platform: Platform){ platform.ready().then(() => { console.log(this.map);
this.loadMap();
});
}
login(){
this.nav.setRoot(HelloIonicPage);
}
loadMap(){
let location = new GoogleMapsLatLng(-34.9290,138.6010);
this.map = new GoogleMap('map', {
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
},
'camera': {
'latLng': location,
'tilt': 30,
'zoom': 15,
'bearing': 50
}
});
this.map.setClickable(true);
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
console.log('Map is ready!');
});
console.log(this.map);
}
}
`
`ion-app.gmaps_cdv .nav-decor{ background-color: transparent !important; }
.home {
#map {
height: 100%;
}
} `
Hi,
you need to create an event when side menu open or close .
for example modify menu in your app.html file by
<ion-menu [content]="content" (ionOpen)="menuOpened()" (ionClose)="menuClosed()">
and for detect if the menu was close or open add this to app.ts
menuClosed() {
this.events.publish('menu:closed', '');
}
menuOpened() {
this.events.publish('menu:opened', '');
}
and in your map page add
this.events.subscribe('menu:opened', () => {
this.map.setClickable(false);
});
this.events.subscribe('menu:closed', () => {
this.map.setClickable(true);
});
hope this help
@AbuHani Working Now with your changes. Thank You So Much.