Answers for "leaflet draw save event"

0

leaflet draw save event

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);
Posted by: Guest on September-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language