【发布时间】:2018-12-12 15:02:20
【问题描述】:
我已经在我的 Angular 6 应用程序中实现了@asymmetrik/ngx-leaflet,除了弹出窗口外一切正常。我在地图上显示了一些标记后,它的显示就像在图片中一样:marker popup
我想在用户单击按钮时更改路线,但是由于 Angular 的 (click) 事件不会在单击事件中触发,我已经在 onClick 中实现了内联函数 javascript 并在单击弹出窗口之前调用了它地图上有标记!所以它不起作用。代码是这样的:
this.listOfStations.map(station => {
if(Object.keys(station.location).length > 0){
this.markers.push(marker([station.location.coordinates[0],station.location.coordinates[1]],{
icon: icon({
iconSize: [ 25, 41 ],
iconAnchor: [ 13, 41 ],
iconUrl: 'assets/marker-icon.png',
shadowUrl: 'assets/marker-shadow.png'
})
})
.bindPopup(`
<div align='center'>
<p style='font-size:18px;font-weight:bold'>Station: ${station.stationCode}</p>
<p style='font-size:14px;font-weight:italic'>${station.description}</p>
<a class='btn btn-xs btn-primary button-me' (click)="${this.consoleThis()}">View</a>
</div>
`)
// .on('click', (e) => {
// this.zone.run(() => {
// this.router.navigate(['/dashboard/station/' + station.stationCode]);
// })
// })
)};
});
谢谢。
【问题讨论】: