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.

Can't get GoogleMap object

See original GitHub issue

Issue description Hi, I am trying to create an OverlayView in order to add customized markers, such as done in this example. To do that I need to get the actual map instance. In the docs I see this should be possible with GoogleMapsAPIWrapper.getNativeMap(). However, when I try this, the Promise never returns.

Steps to reproduce and a minimal demo of the problem See example here. Where the code: this.mapsAPIWrapper.getNativeMap().then((map) => { console.log(‘Got map!’) console.log(map); }); Never returns from getNativeMap() call.

_Use https://plnkr.co or similar – try this template as a starting point: http://plnkr.co/edit/YX7W20?p=preview

What steps should we try in your demo to see the problem?

Current behavior Not returning from function call - Promise not resolved.

Expected/desired behavior Promise resolved - returning map instance.

angular2 & angular-google-maps version agm/core": “^1.0.0-beta.2” Angular 5.

Other information

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

6reactions
agborkowskicommented, Mar 30, 2018
(mapReady)="onMapReady($event)" 

in component ulll get map instance

public onMapReady(e) {
		console.log('map instance', e);
	}
3reactions
JimmyTheNerdcommented, Mar 31, 2018

Based on @agborkowski example:

HTML:

<agm-map (mapReady)="mapReady($event)"></agm-map>

TS:

mapReady(map) {
    var marker = new google.maps.Marker({
        position: {lat:40.706130, lng: -74.076870},
        map: map,
        title: 'Hello World!'
    });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get GoogleMap object · Issue #1354 - GitHub
Issue description Hi, I am trying to create an OverlayView in order to add customized markers, such as done in this example.
Read more >
Get google.maps.Map instance from a HTMLElement
You can't get google.maps.Map object from DOM Element ,on which Google Maps object have been constructed. google.maps.Map is just a wrapper, which controls ......
Read more >
Maps JavaScript API | Google Developers
A registry for MapType instances, keyed by MapType id. This class extends MVCObject . When using v=beta , can be accessed by calling...
Read more >
How to Create a Google Map Object with the Maps JavaScript ...
To use the Google Maps JavaScript API, you first need to create an instance of the Google Maps object.
Read more >
Google Maps Reference - W3Schools
HTMLElement, Specifies in what HTML element to put the map. MapOptions, A MapOptions object that holds the map initialization variables/options ...
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