Javascript 使用api“显示google地图时出错”;无法读取属性';getCenter';“未定义”的定义;

Javascript 使用api“显示google地图时出错”;无法读取属性';getCenter';“未定义”的定义;,javascript,ionic4,Javascript,Ionic4,我试图在我的ionic应用程序中显示google地图,但我不断收到错误“无法读取未定义的属性'getCenter'” 这是我的密码: 从“@angular/core”导入{Component,OnInit,ViewChild}; 宣布让谷歌; @组成部分({ 选择器:“应用程序地图”, templateUrl:'./map.page.html', 样式URL:['./map.page.scss'], }) 导出类MapPage实现OnInit{ @ViewChild('map',{static

我试图在我的ionic应用程序中显示google地图,但我不断收到错误“无法读取未定义的属性'getCenter'”

这是我的密码:


从“@angular/core”导入{Component,OnInit,ViewChild};
宣布让谷歌;
@组成部分({
选择器:“应用程序地图”,
templateUrl:'./map.page.html',
样式URL:['./map.page.scss'],
})
导出类MapPage实现OnInit{
@ViewChild('map',{static:false})mapElement;
地图:任何;
构造函数(){}
恩戈尼尼特(){
console.log(“ngOnInIt”)//测试
}
//当页面即将出现时激发
ionViewWillEnter(){
console.log(“ionViewWillEnter”)//测试
}
//加载页面时激发
ionViewDidEnter(){
console.log(“IonViewDiCenter”)
//coords前往格里菲斯大学黄金海岸
让latLng=new google.maps.latLng(-27.962621728375595153.3814389259848);
让mapOptions={
中心:拉特林,
缩放:15,
mapTypeId:google.maps.mapTypeId.ROADMAP
}
让marker=new google.maps.marker({
map:this.map,
动画:google.maps.animation.DROP,
位置:this.map.getCenter(),
});
//创建映射的新实例
this.map=new google.maps.map(this.mapeElement.nativeElement,mapOptions);
}
}
如您所见,我试图在“IonViewDiCenter”阶段创建地图,但我一直遇到相同的问题。有人能帮忙吗?谢谢