Solvedangular google maps getNativeMap() and getBounds() Promise never gets resolved neither rejected

I'm trying to get native map instance to do fitBounds but it's Promise never gets resolved neither rejected.
I've already tried to do this in a component inside sebm-google-map but it also didn't work.




@angular/cli: 1.0.0-beta.32.3
node: 6.9.5
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/platform-server: error
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8
23 Answers

✔️Accepted Answer

Hi all! You do not need a child directive to obtain your native map instance. You can get it subscribing for mapReady events on AgmMap object.

@ViewChild(AgmMap) agmMap;
	this.agmMap.mapReady.subscribe(map => {
		var trafficLayer = new google.maps.TrafficLayer();

Other Answers:

@giorgiofellipe It works!

I did like in comment (#715) (there are outdated, not working code example).
Sorry, I don't have time to full plunkr example, may be later.
Try to use child directive.

  selector: 'my-custom-extension'
export class MyCustomExtension implements AfterViewInit{
  constructor(private _wrapper: GoogleMapsAPIWrapper) {

  ngAfterViewInit() {
    this._wrapper.getNativeMap().then((m) => {
      console.log('native map',m);
    }, err=>{

In case anyone still has problems, you don't need even a @ViewChild, as the mapReady is an event on the map component, so in your template just do <agm-map (mapReady)="onMapReady($event)"... and in your component define the onMapReady(map) method.

More Issues: