使用googlemaps javascript API时,Typescript错误在ionic2中找不到名称"google" [英] Typescript Error Cannot find name 'google' in ionic2 when using googlemaps javascript API

查看:101
本文介绍了使用googlemaps javascript API时,Typescript错误在ionic2中找不到名称"google"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循Joshua Morony在Ionic 2视频教程中使用的Google地图入门. 我想在我的应用程序中使用Google Maps,但最终出现打字稿错误.这是 pages/home/home.ts文件

I am following Joshua Morony's Getting Started with Google Maps in Ionic 2 video tutorial. I want to use google maps in my application and i end up with a typescript error. this is a part of the pages/home/home.ts file

initMap(){
let latLng= new google.maps.LatLng(6.929848, 79.857407);

let mapOpt={
  center : latLng,
  zoom : 15,
  mapTypeId :google.maps.MapTypeId.ROADMAP
};

this.map= new google.maps.Map(this.mapElement.nativeElement,mapOpt);}

我尝试了npm install --save @types/googlemaps

但是它仍然给我相同的打字稿错误打字稿错误 找不到名称"google"

but it still gives me the same typescript error Typescript Error Cannot find name 'google'

推荐答案

我通过安装解决了该问题:

I solved it by installing:

$npm install @types/googlemaps --save-dev

这篇关于使用googlemaps javascript API时,Typescript错误在ionic2中找不到名称"google"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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