My final goal is to build a goolgle map compoment with Angular2.
Google map has its own library, and it can be initialized using <script>
tag with or without callbak.
http://maps.googleapis.com/maps/api/js?v=3&sensor=false&callback=initialize
I want to use this callback function to initialize an angular2 component or invoke a function of a angular2 component. e.g.,
http://maps.googleapis.com/maps/api/js?v=3&sensor=false&callback=MapCompnent.initMap
Since it is a static method, it seems not possible for me.
Another way I approach is is to check google maps variable like this
get googleMapReady() {
return window.google.maps;
}
and use it with *ngIf="googleMapReady"
.
Before I try the second approach, I was wondering if it is possible to call Angular2 component instance function from window level callbacks?
If so, then where can I find those examples?