Reputation: 3055
According to Angluar-cli documentation here, I succeed to import any third party library and then to use typings (dt and custom). Youhouou !
But for Google types, I have to prefix all my types by the google.maps
namespace :
let geocoder = new google.maps.Geocoder();
What can I do to use short names for types like this :
let geocoder = new Geocoder();
Thanks for any suggestion.
Detail of my Google Maps import are here : Getting started - How to use Google maps api with angular-cli
==== EDIT ====
The @Nikky answer show me the mistake with the google namespace : It will be available at runtime only after the google maps script will be loaded.
So the problem is located in all the constructor()
and ngOnInit()
that use the google.map types :
constructor() {
this.load(); //will begin goooglemaps script loading
this.onReady().then(() => { //subscribtion to script loaded event
this.geocoder = new google.maps.Geocoder();//'google is not defined' at runtime
});
}
Upvotes: 0
Views: 356
Reputation: 549
You can import the namespace and assign a name to it
import Geocoder = google.maps.Geocoder;
And then use it as if you were using native Geocoder API
let geocoder = new Geocoder();
Upvotes: 1