我正在 ionic 3 中使用 AlertController
实现一个警告对话框,如下所示
let alert = this.alertCtrl.create({
title: 'Low battery',
subTitle: '10% of battery remaining',
buttons: ['Dismiss']
});
alert.present();
此警报对话框在谷歌地图上方可见,但我无法点击此警报按钮,任何对警报对话框的点击仍被视为我正在点击其下方的谷歌地图。即使在 map 上方显示警告对话框,我仍然可以像往常一样与 map 进行交互,我可以单击 map 中的任何标记,我可以放大、缩小。
最佳答案
您需要在显示警报时将 map 设置为不可点击,然后在关闭时将其设置回可点击:
public showAlert(): void {
// Disable the map
this.map.setClickable(false);
let alert = this.alertCtrl.create({
title: 'Low battery',
subTitle: '10% of battery remaining',
buttons: [
{
text: 'Dismiss',
role: 'cancel',
handler: () => {
// Enable the map again
this.map.setClickable(true);
}
}
]
});
// Show the alert
alert.present();
}
关于angular - Ionic 3 - 无法点击谷歌地图上方显示的警报对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45500031/