question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getNativeMap() and getBounds() Promise never gets resolved neither rejected

See original GitHub issue

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.

    <sebm-google-map>
      <map-content></map-content>
    </sebm-google-map>

Plunker: http://plnkr.co/edit/VKqwVSUlzFJjHPX7cQm4?p=preview

v0.17.0

@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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:22 (2 by maintainers)

github_iconTop GitHub Comments

15reactions
aikedacommented, Apr 26, 2017

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;
ngAfterViewInit(){
	this.agmMap.mapReady.subscribe(map => {
		var trafficLayer = new google.maps.TrafficLayer();
		trafficLayer.setMap(map);
	});
}
4reactions
adrianharacommented, Sep 8, 2017

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

getNativeMap() and getBounds() Promise never gets resolved ...
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...
Read more >
what happens when a Promise never resolves? - Stack Overflow
If you rewrite simple to not use async / await , the code that goes after the await statement will have to be...
Read more >
Promise - JavaScript - MDN Web Docs
A promise is said to be settled if it is either fulfilled or rejected, but not pending. Flowchart showing how the Promise state...
Read more >
Let's talk about how to talk about promises | JavaScript
If the other promise is rejected, your original promise will reject itself with the other promise's rejection reason; If the other promise never...
Read more >
JavaScript Promise Tutorial – How to Resolve or Reject ...
The new Promise() constructor returns a promise object. ... A promise that is either resolved or rejected is called settled . states_2 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found