Usually in a plain javascript site, I can use the following script to reference google maps api and set the callback
function with initMap
.
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script>
What I observed is the initMap
function in the plain javascript site is under the window scope, and it can be referenced in the script parameter settings - ?callback=initMap
, but once I write a component in angular2 with a component method called initMap
, the initMap
will be under the scope of my component. Then the async loading script I set up in the index will not be able to catch my component initMap
method.
Specifically, I 'd like to know how to achieve the same thing in Angular2
?
PS: I know there is an
angular2-google-maps
component available inalpha
vianpm
, but it currently is shipped with limited capability, so I 'd like to know how to load it in an easier way without using another component so I can just use google maps api to implement my project.