首页 > 解决方案 > 打字稿错误找不到名称'google'

问题描述

如果我将文件保存两次,但不知道为什么 google.maps.ts

ngOnInit(){
    this.initMap();
}

initMap(){
    let coords = new google.maps.LatLng(37.992667,-1.1146491);
    let mapOptions: google.maps.MapOtpions= {
        center: coords,
        zoom: 17,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    this.map = new google.maps.Map(this.mapElement.nativeElement,
    mapOptions)


}

}

这是错误代码...

Typescript: C:/ionic/restaurante/IESAljada/src/components/google-map/google-map.ts, line: 22

  L21:  initMap(){
  L22:      let coords = new google.maps.LatLng(37.992667,-1.1146491);
  L23:      let mapOptions: google.maps.MapOtpions= {

标签: google-mapsionic-frameworkionic2ionic3ionic-native

解决方案


google.maps.MapOtpions看起来像一个错字。你的意思是google.maps.MapOptions


推荐阅读