Using Visual Studio 2015 I added google maps to one of my pages and inside that page’s TypeScript file whenever I referenced google I was getting the TypeScript error: Cannot find name ‘google’.
I was stuck on this for a few hours because I followed tutorials like this and did everything as explained but this error persisted. What I eventually realized was that I needed to include the TypeScript definition files for google maps (which I fetched from this repo) in my application so I added this inside the typings folder of the application structure.
Discussion
So although I resolved the error I wanted to know if this is the expected procedure when it comes to using the Google JavaScript API in an application because all tutorials relating to Ionic 2 and Google maps do not bring this up.
What I would like to know is:
Is this just something caused by the IDE I’m using?
Is there likely to be a way in the future for me to not have to manually add the definition files myself?
Ionic info(in case it has any relevance to this discussion)
Cordova CLI: 5.4.0
Gulp version: CLI version 3.8.11
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.4
Ionic CLI Version: 2.0.0-beta.24
Ionic App Lib Version: 2.0.0-beta.14
OS: Windows 8.1
Node Version: v4.4.2
This discussion didnt seem to take off but i’ve found a more complete solution than the one I mentioned in my question which was copying and pasting things into the typings folder.
Thanks for the explanation, am following your steps and am still getting cannot find name ‘google’.
Currently I use Visual Studio Code and the problem pops up in the IDE and on ionic serve in my terminal.
Curious if there is another step I must do after doing all of your 3 steps?
Both work for me but yours might be the better way because mine creates another typings folder inside the already existing typings folder e.g. typings > typings > globals > google.maps and your approach doesn’t so the result looks like this. typings > globals > google.maps
hi guys i had the same error
i add this import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native'; to my ts file
and it’s work fine for me ,i hope for you too.
Hi I am facing issue while building the app. I am under tight timelines and this is really killing my delivery schedule. I had no issue with ionic serve and testing it on the browser. Any help would be highly appreciated. Thanks again.
ionic-app-scripts build
[08:16:22] ionic-app-scripts 0.0.38
[08:16:23] build prod started …
[08:16:23] clean started …
[08:16:23] clean finished in 5 ms
[08:16:23] copy started …
[08:16:23] ngc started …
[08:16:24] lint started …
[08:16:25] copy finished in 2.21 s
[08:16:56] lint finished in 32.03 s
[08:17:29] Error: Error at G:/Projects/.tmp/components/map/map.ts:10:15
[08:17:29] Cannot find namespace ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:22:27
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:27:18
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:32:19
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:37:26
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:40:24
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:42:21
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/components/map/map.ts:44:26
[08:17:29] Cannot find name ‘google’.
[08:17:29] Error at G:/Projects/.tmp/pages/list-page/list-page.ngfactory.ts:642:72
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] Error at G:/Projects/.tmp/pages/list-page/list-page.ngfactory.ts:648:72
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] Error at G:/Projects/.tmp/pages/list-page/list-page.ngfactory.ts:846:72
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] Error at G:/Projects/.tmp/pages/list-page/list-page.ngfactory.ts:852:72
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] Error at G:/Projects/.tmp/pages/detail-page/detail-page.ngfactory.ts:708:73
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] Error at G:/Projects/.tmp/pages/detail-page/detail-page.ngfactory.ts:719:73
[08:17:29] Supplied parameters do not match any signature of call target.
[08:17:29] ngc failed
[08:17:29] ionic-app-script task: “build”
[08:17:29] Error: Error