📜  传单绘制保存事件 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:47.308000             🧑  作者: Mango

代码示例1
L.EditToolbar.include({
  getActions: function (handler) {
    var actions = [
      {
        title: L.drawLocal.edit.toolbar.actions.save.title,
        text: L.drawLocal.edit.toolbar.actions.save.text,
        callback: this._save,
        context: this
      },
      {
        title: L.drawLocal.edit.toolbar.actions.cancel.title,
        text: L.drawLocal.edit.toolbar.actions.cancel.text,
//        callback: this.disable,  // --- original
        callback: this._cancel,    // --- changed
        context: this
      }
    ];

    if (handler.removeAllLayers) {
      actions.push({
        title: L.drawLocal.edit.toolbar.actions.clearAll.title,
        text: L.drawLocal.edit.toolbar.actions.clearAll.text,
        callback: this._clearAllLayers,
        context: this
      });
    }

    return actions;
  },

// --- new -----------------
  _cancel: function() {
    this.disable();
    this._map.fire('draw:editcancel');
  }  
});

function processCancel(e) {
  console.log('draw canceled');
}

map.on('draw:editcancel', processCancel);