I'm trying to add the google maps service
in my angular 2 app
, but I'm getting following error: Cannot find namespace 'google'.
As seen on similar questions, I defined declar var google: any
outside the class and I'm loading the google-maps api
like this:
imports: [
AgmCoreModule.forRoot({
apiKey: "AIzaSyBfPIuViPbFbOzByKGGNKSuvNrbocxNyqE",
libraries: ["places"]
}),
...
]
I also installed typings install dt~google.maps --global
, but it's still not working.
After adding
/// <reference path="./../../../typings/globals/google.maps/index.d.ts"/>
into the class in which I used google.maps
, everything worked fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.