# Google maps TypeScript error: Cannot find name 'google' - discussion

**URL:** <https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990>\
**Category:** ionic-v3\
**Created:** [April 21, 2016, 11:09am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990 "2016-04-21T11:09:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![william\_harris](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/william_harris/32/101865_2.png) [@william\_harris](https://forum.ionicframework.com/u/william_harris)\
**Post date:** [April 21, 2016, 11:09am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/1 "2016-04-21T11:09:58Z")

</div>

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](http://www.gajotres.net/ionic-2-integrating-google-maps/) 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](https://github.com/DefinitelyTyped/DefinitelyTyped)) 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:

1. Is this just something caused by the IDE I’m using?

2. 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

---

<div class="post-metadata">

**Author:** ![william\_harris](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/william_harris/32/101865_2.png) [@william\_harris](https://forum.ionicframework.com/u/william_harris)\
**Post date:** [May 19, 2016, 8:50am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/2 "2016-05-19T08:50:14Z")

</div>

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.

Instead what you can do is:

1. Install the [TypeScript Definition Manager CLI](https://github.com/typings/typings) using npm… `npm install typings --global`

2. Then use your CLI to navigate into your Ionic 2 project’s folder

3. And finally, install the google map definition files using the typings CLI… `typings install dt~google.maps --global`

* * *

Once you have done this you should end up with the following files in your project’s `typings > global > google.maps` directory:

- index.d.ts

- typings.json

Also, you don’t need to add reference path to the top of the files that use google maps. In my original solution I did have to do this.

[This issue](https://github.com/typings/typings/issues/514) on GitHub helped me with step 3!

---

<div class="post-metadata">

**Author:** ![dmastag](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dmastag/32/104373_2.png) [@dmastag](https://forum.ionicframework.com/u/dmastag)\
**Post date:** [June 4, 2016, 5:51pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/3 "2016-06-04T17:51:28Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dmastag](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dmastag/32/104373_2.png) [@dmastag](https://forum.ionicframework.com/u/dmastag)\
**Post date:** [June 4, 2016, 5:55pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/4 "2016-06-04T17:55:05Z")

</div>

Ok, found the problem on my side. I think that step 2 should be changed from

> Then use your CLI to navigate into your Ionic 2 project’s typings folder

into

> Then use your CLI to navigate into your Ionic 2 project’s folder

It was working after I did that.  
Thanks for the tip, this was bugging me for so long!

---

<div class="post-metadata">

**Author:** ![KhanSadique](https://avatars.discourse-cdn.com/v4/letter/k/bbe5ce/32.png) [@KhanSadique](https://forum.ionicframework.com/u/KhanSadique)\
**Post date:** [June 6, 2016, 4:39am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/5 "2016-06-06T04:39:53Z")

</div>

> [@dmastag](#):
>
> Then use your CLI to navigate into your Ionic 2 project’s typings folder

Dear, Can you provide sample code, which is running properly with google.maps.

---

<div class="post-metadata">

**Author:** ![dmastag](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/dmastag/32/104373_2.png) [@dmastag](https://forum.ionicframework.com/u/dmastag)\
**Post date:** [June 6, 2016, 6:04am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/6 "2016-06-06T06:04:01Z")

</div>

Is this in response to the typings problem or do you need to know how to implement google maps into ionic2?

---

<div class="post-metadata">

**Author:** ![william\_harris](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/william_harris/32/101865_2.png) [@william\_harris](https://forum.ionicframework.com/u/william_harris)\
**Post date:** [June 6, 2016, 8:21am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/7 "2016-06-06T08:21:06Z")

</div>

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`

I will update step 2 to what you said 🙂

---

<div class="post-metadata">

**Author:** ![neerav94](https://avatars.discourse-cdn.com/v4/letter/n/a587f6/32.png) [@neerav94](https://forum.ionicframework.com/u/neerav94)\
**Post date:** [July 28, 2016, 6:49pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/8 "2016-07-28T18:49:47Z")

</div>

hey @dmastag  
I am still getting the same error… Do you have any solution or know why is it happening?

Error: Cannot find name ‘google’.  
namespace google

---

<div class="post-metadata">

**Author:** ![DigitalIQ](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/digitaliq/32/133787_2.png) [@DigitalIQ](https://forum.ionicframework.com/u/DigitalIQ)\
**Post date:** [August 3, 2016, 10:38am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/9 "2016-08-03T10:38:48Z")

</div>

> [@william\_harris](#):
>
> typings install dt~google.maps --global

Thank you so much… it worked 🙂

---

<div class="post-metadata">

**Author:** ![3jFernando](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/3jfernando/32/111682_2.png) [@3jFernando](https://forum.ionicframework.com/u/3jFernando)\
**Post date:** [November 19, 2016, 9:34pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/10 "2016-11-19T21:34:57Z")

</div>

Hola.  
Tengo el mismo problema, no he podido darle solucion, espero me ayuden.

 ![image](https://global.discourse-cdn.com/ionicframework/original/3X/c/6/c6677ea7696a6df60383f316a34ecb35ea7240a3.PNG)

---

<div class="post-metadata">

**Author:** ![SonecaJones](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@SonecaJones](https://forum.ionicframework.com/u/SonecaJones)\
**Post date:** [November 29, 2016, 3:18pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/11 "2016-11-29T15:18:12Z")

</div>

Same problem here… RC2

---

<div class="post-metadata">

**Author:** ![reedrichards](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@reedrichards](https://forum.ionicframework.com/u/reedrichards)\
**Post date:** [November 29, 2016, 3:21pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/12 "2016-11-29T15:21:12Z")

</div>

npm install @types/googlemaps --save-dev

(to install the google-map typescript definition for Ionic2 \>= RC.0)

---

<div class="post-metadata">

**Author:** ![ridlam](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@ridlam](https://forum.ionicframework.com/u/ridlam)\
**Post date:** [December 7, 2016, 1:03am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/13 "2016-12-07T01:03:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ajsivsan](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@ajsivsan](https://forum.ionicframework.com/u/ajsivsan)\
**Post date:** [December 14, 2016, 2:22pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/14 "2016-12-14T14:22:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [December 31, 2016, 8:50am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/15 "2016-12-31T08:50:01Z")

</div>

Did you manage to solve this?

I am facing the same problem.

I do have the following in my `index.html`

`<script src="http://maps.google.com/maps/api/js?key=XXXXX"></script>`

and in my `pckage.json`

`"@types/googlemaps": "^3.25.40",`

When I was using `Ionic 2 beta` it worked, but since an upgrade to `rc3`, I get:

> `Cannot find namespace 'google'`

and

> `Cannot find name 'google'.`

when trying to:

`public map: google.maps.Map = null;`

However, in my IDE, when I click on `google.maps`, it takes me to:

`node_modules/@types/googlemaps/index.d.ts``declare namespace google.maps {`

as expected.

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [December 31, 2016, 9:44am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/16 "2016-12-31T09:44:59Z")

</div>

I solved this my adding the following to `declarations.d.ts`

`/// <reference path="../node_modules/@types/googlemaps/index.d.ts" />`

---

<div class="post-metadata">

**Author:** ![vks\_gautam1](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vks\_gautam1](https://forum.ionicframework.com/u/vks_gautam1)\
**Post date:** [January 3, 2017, 7:39am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/17 "2017-01-03T07:39:04Z")

</div>

> [@richardmarais](#):
>
> /// \<reference path=“…/node\_modules/@types/googlemaps/index.d.ts” /\>

i followed this tutorial  
[http://devfanaticblog.com/google-maps-autocomplete-for-ionic-2-applications/#more-85](http://devfanaticblog.com/google-maps-autocomplete-for-ionic-2-applications/#more-85)  
i found the following error "Cannot find name ‘google’.

---

<div class="post-metadata">

**Author:** ![richardmarais](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/richardmarais/32/101456_2.png) [@richardmarais](https://forum.ionicframework.com/u/richardmarais)\
**Post date:** [January 3, 2017, 9:50am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/18 "2017-01-03T09:50:18Z")

</div>

Do you have the folloiwng in your `index.html`?

`<script src="http://maps.google.com/maps/api/js?key=XXXXX"></script>`

---

<div class="post-metadata">

**Author:** ![vks\_gautam1](https://avatars.discourse-cdn.com/v4/letter/v/ed655f/32.png) [@vks\_gautam1](https://forum.ionicframework.com/u/vks_gautam1)\
**Post date:** [January 3, 2017, 10:59am UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/19 "2017-01-03T10:59:04Z")

</div>

yes i have done that

---

<div class="post-metadata">

**Author:** ![dpucar](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@dpucar](https://forum.ionicframework.com/u/dpucar)\
**Post date:** [January 4, 2017, 1:49pm UTC](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990/20 "2017-01-04T13:49:37Z")

</div>

I solved this, here is what you have to do:

1. `npm install @types/googlemaps --save-dev`

2. `<script src="http://maps.google.com/maps/api/js?key=XXXXX"></script>` in `index.html`

3. `declare module 'googlemaps';` into `declarations.d.ts`

4. `import {googlemaps} from 'googlemaps';` in class where you using maps

[Next page](https://forum.ionicframework.com/t/google-maps-typescript-error-cannot-find-name-google-discussion/49990.md?page=2)
