Open jiayuya opened 3 years ago
只能改源码了,我修改了一些可以,具体是找到在源码里面找到'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) }) 就行了
this.drawingManager.addEventListener('overlaycancel', this.overlaycancel); this.drawingManager.addEventListener('overlaycomplete', this.overlaycomplete);
成功的回调正常,失败的没有触发