你好我正在尝试使用npm包"@types/googlemaps": "^3.30.7",
,我正在尝试实现一个组件,这将允许我创建我需要创建的任何东西,因为谷歌没有定义。
我多次跑npm install
。
我将其导入为:import {} from '@types/googlemaps';
并实现它:
ngOnInit(): void {
var location = this.googleMapService.getCurrentLocation();
let mapProp = {
center: new google.maps.LatLng(this.googleMapService.currentLatitude, this.googleMapService.currentLogitude),
zoom: 15,
mapTypeId: google.maps.MapTypeId.HYBRID
};
this.map = new google.maps.Map(this.googleMap.nativeElement, mapProp);
this.map.addListener('click', (event) => this.addMarker(event));
this.addMarkerAtCurrentLocation();
}
如果有人可以告诉我该寻找什么或为什么它未定义我会很感激。
答案 0 :(得分:0)
我找到了这个问题。在我的index.html页面上,我需要添加
<script src="http://maps.googleapis.com/maps/api/js"></script>
在脚本部分。