allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 516 forks source link

[DOCS] map-lazy-inint Without Button #842

Open ghost opened 6 years ago

ghost commented 6 years ago

Steps to reproduce and a minimal demo(Plunker Example)

Attempt to use lazy-init outside of the ng-click used in the example documentation. This also occurs when you try to run NgMap.initMap() in an $http callback.

https://plnkr.co/edit/oqQ4HiGqt4rpsEOLMrNS?p=preview

Current behavior

'TypeError: Cannot read property 'map' of undefined'

Expected/desired behavior

Wrapping NgMap.initMap() with NgMap.getMap().then(... gets rid of the error.

Plunker that fixes the issue - https://plnkr.co/edit/lkaVgTxsjqgD2oQCgrWh?p=preview