Skip to content

Commit

Permalink
Don't enable edit/delete handlers if no layers available. refs #136
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtoye committed Sep 30, 2013
1 parent faf3ef2 commit 97213f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/edit/handler/EditToolbar.Delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ L.EditToolbar.Delete = L.Handler.extend({
},

enable: function () {
if (this._enabled) { return; }
if (this._enabled || !this._hasAvailableLayers()) {
return;
}

L.Handler.prototype.enable.call(this);

Expand Down Expand Up @@ -107,5 +109,9 @@ L.EditToolbar.Delete = L.Handler.extend({

_onMouseMove: function (e) {
this._tooltip.updatePosition(e.latlng);
},

_hasAvailableLayers: function () {
return this._deletableLayers.getLayers().length !== 0;
}
});
8 changes: 7 additions & 1 deletion src/edit/handler/EditToolbar.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ L.EditToolbar.Edit = L.Handler.extend({
},

enable: function () {
if (this._enabled) { return; }
if (this._enabled || !this._hasAvailableLayers()) {
return;
}

L.Handler.prototype.enable.call(this);

Expand Down Expand Up @@ -237,5 +239,9 @@ L.EditToolbar.Edit = L.Handler.extend({

_onMouseMove: function (e) {
this._tooltip.updatePosition(e.latlng);
},

_hasAvailableLayers: function () {
return this._featureGroup.getLayers().length !== 0;
}
});

0 comments on commit 97213f8

Please sign in to comment.