I'm using angular2-google-maps version 0.12.0 with ionic2 beta 11.
My code looks like this: http://plnkr.co/edit/IzcUBS4gCKDfGpb3TCvi?p=preview
I tried to post most of my code, but i dont know how to make the plunker code work.
And i am importing the all the necessary things.
I'm opening the component with navController.push().
The strange thing is that i just see a grey box with google control icons (like + and - for zoom).
But when i'm opening or closing the chrome developer tools, the correct view of map appears.
Is it a bug or am i doing something wrong?
Edit:
I can reproduce the behavior with native maps implementation. When i start the map, i can only see the grey map, but if i start it with setTimeout and a short wait time, the map is showed correctly. Any idea what the problem could be?
Edit2:
With the native map, i can show the map with google.maps.event.trigger(myMap, "resize");
Is there a possibility to do the same with angular-maps?
Yes, it's the default google-maps resize problem, I solved by using this.map.triggerResize() in the method ionViewDidLoad of my PageComponent, where you can reference your map (if you have just one in that page) with @ViewChild(SebmGoogleMap) map: SebmGoogleMap
@Jamby93 thx for the solution. This is right solution for the problem. Closing this as this is no bug.
this needs to be in docs
this.map.triggerResize() for lazy
Getting same issue. Thanks in advance
Component
import { AgmMap } from '@agm/core';
@ViewChild(AgmMap) map: AgmMap;
initialize() {
//set google maps defaults
this.zoom = 12;
this.latitude = 12.9777688;
this.longitude = 77.6345873;
}
openMapPopup() {
this.initialize();
this.map.triggerResize()
jQuery('#map-modal').modal('show');
}
Html
For those who are still struggling with this issue, Just FYI, calling this.map.triggerResize() inside a setTimeout function will make it work.
Most helpful comment
Yes, it's the default google-maps resize problem, I solved by using
this.map.triggerResize()in the methodionViewDidLoadof my PageComponent, where you can reference your map (if you have just one in that page) with@ViewChild(SebmGoogleMap) map: SebmGoogleMap