google-maps - Polygon 上的 GoogleMap dragend 事件会破坏 Material Angular Snackbar
问题描述
dragend
在多边形上使用 GoogleMaps 侦听器中的快餐栏时,
let polygon = new google.maps.Polygon({
map: this.map.googleMap,
paths: coords.map(c => ({
lat: c.latitude,
lng: c.longitude
})),
strokeColor: `#caa052`,
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: `#ffffb1`,
fillOpacity: 0.35,
draggable: true
});
google.maps.event.addListener(polygon, "dragend", () => {
this._snackBar.open("dragend");
});
小吃店消息卡在左上角并且永远不会消失。
可以在https://google-map-drag-breaks-snackbar.stackblitz.io/找到工作示例。代码可以在https://stackblitz.com/edit/google-map-drag-breaks-snackbar?file=src%2Fapp%2Fsnack-bar-overview-example.ts找到。
有什么办法可以解决这个问题吗?
解决方案
需要使用NgZone.run
,因为我没有使用map-polygon
绑定。
constructor(private _snackBar: MatSnackBar, private _ngZone: NgZone) {}
google.maps.event.addListener(polygon, "dragend", () => {
this._ngZone.run(() => this._snackBar.open("dragend"));
});
推荐阅读
- cmake - ExternalProject_Add:如何在您的项目中使用构建依赖项?
- sharepoint - 将辅助管理员添加到 SP 站点,包括 OneDrive 站点、更改站点区域设置并删除辅助管理员帐户 - PowerShell
- redis - 如何删除与模式(原子)匹配的 redis 键,其中键可能包含空格和双引号?
- python-2.7 - 无法在 HP-UX 上安装 PIP
- ios - 将“动态字体大小”与 NSAttributedString 一起使用
- azure - 使用带有 azure B2C 的自定义策略获取用户个人资料图片
- visual-c++ - 在嵌套模式对话框中无法干净地关闭 MFC 应用程序(2 深)
- amazon-web-services - 来自 Lambda 的经过身份验证的 API 网关调用
- python - 函数 re.findall 返回带有字符串的列表,只包含一个符号
- flutter - 我想在导航前停止视频播放器