Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawingManager overlaycancel事件回调没有触发 #18

Open
jiayuya opened this issue Aug 31, 2021 · 1 comment
Open

DrawingManager overlaycancel事件回调没有触发 #18

jiayuya opened this issue Aug 31, 2021 · 1 comment

Comments

@jiayuya
Copy link

jiayuya commented Aug 31, 2021

this.drawingManager.addEventListener('overlaycancel', this.overlaycancel);
this.drawingManager.addEventListener('overlaycomplete', this.overlaycomplete);

成功的回调正常,失败的没有触发

@shenlan42
Copy link

只能改源码了,我修改了一些可以,具体是找到在源码里面找到'overlaycomplete',定位到i.prototype._dispatchOverlayComplete,然后再下面加上
// 给源码添加上取消的回调事件
i.prototype._dispatchOverlayCancel = function (m, n) {
var l = { overlay: m, drawingMode: this._drawingType }; if (n) { l.calculate = n.data || null; l.label = n.label || null } this.dispatchEvent(this._drawingType + "cancel", m); this.dispatchEvent("overlaycancel", l);
};
再定位'_dispatchOverlayComplete'这个函数, 找到n._dispatchOverlayComplete(p),在其下面加上n._dispatchOverlayCancel(p)
再定位‘document.getElementById("cancelOperate")',在这个函数下面添加n.DrawingManager._dispatchOverlayCancel(l, r)
然后再调用的时候DrawingManager.addEventListener('overlaycancel', function (e) {
console.log('取消',e.overlay)
})
就行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants