我使用javascript谷歌地图组件在角5前端框架
export class MapComponent implements OnInit {
ngOnInit() {
this.initializeGMap()
}
initializeGMap() {
var myLatlng = new google.maps.LatLng(12,77);
var mapOptions = {
zoom: DEFAULT_MAP_ZOOM,
center: myLatlng,
scrollwheel: true,
styles: MAP_STYLE
};
this.map = new google.maps.Map(document.getElementById("map"), mapOptions);
this.initOnMapClickListener();
}
initOnMapClickListener() {
google.maps.event.addListener(this.map, 'click', function(event) {
var selectedLocation = new google.maps.LatLng(event.latLng.lat(), event.latLng.lng());
this.addMarker(selectedLocation)
});
}
addMarker(latlng) {
var marker = new google.maps.Marker({
position: latlng,
map: this.map,
icon: './assets/map_marker.png'
});
}
}
以上是我的打字稿文件,它有三个功能
遗漏的类型错误:无法读取空的特性“addMarker”
这是控制台的错误我得到什么,如果我跑角应用
请帮助了解如何调用JavaScript回调内部的打字稿功能
使用这样的箭头功能qazxsw POI绑定到qazxsw POI的词汇范围,尝试调用函数 -
=>