找不到命名空间'google' [英] Cannot find namespace 'google'

查看:221
本文介绍了找不到命名空间'google'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Ionic2 beta升级到RC3后,我跑了:

npm install --save @ types / google-maps



将以下内容添加到我的 package.json中

code $:b
$ b

@ types / google-maps:^ 3.2.0,



我的 index.html 有:

 < script src =http://maps.google.com/maps/api/js>< / script> 
< script src =cordova.js>< / script>

我的代码包含:

  declare var google:any; 
...
public map:google.maps.Map = null;

但是当我运行 ionic serve $ b


无法找到名称空间'google'。


在我的IDE(VSC)中,如果我点击 google ,它会带我到 node_modules \@types\googlemaps\index.d.ts 这似乎有正确的定义。



任何想法都可以使用。

解决方案

地图。您可以查看此处



实际的插件此处

 离子插件添加cordova-plugin-googlemaps  - 变量API_KEY_FOR_ANDROID =YOUR_ANDROID_API_KEY_IS_HERE - 变量API_KEY_FOR_IOS =YOUR_IOS_API_KEY_IS_HERE


After upgrading from Ionic2 beta to RC3,

I ran:

npm install --save @types/google-maps

which added the following to my package.json:

"@types/google-maps": "^3.2.0",

My index.html has:

  <script src="http://maps.google.com/maps/api/js"></script>
  <script src="cordova.js"></script>

My code contains:

declare var google: any;
...
public map: google.maps.Map = null;

But I get the following error when I run ionic serve:

Cannot find namespace 'google'.

In my IDE (VSC), if I click on google, it takes me to node_modules\@types\googlemaps\index.d.ts which seems to have the correct definition.

Any ideas appreciated.

解决方案

Actually Ionic native already has google maps. You can check it out here

The actual plugin is here.

ionic plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"

这篇关于找不到命名空间'google'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆