Skip to content

Commit

Permalink
Merge pull request #175 from bhell/additional-draw-events
Browse files Browse the repository at this point in the history
Events draw:editstart and draw:editstop added
  • Loading branch information
jacobtoye committed Aug 21, 2013
2 parents 9fde651 + 3c3d6a8 commit 652c211
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ Triggered when the user has finshed a particular vector or marker.
| --- | --- | ---
| layerType | String | The type of layer this is. One of: `polyline`, `polygon`, `rectangle`, `circle`, `marker`

#### draw:editstart

Triggered when the user starts edit mode by clicking the edit or remove tool button.

| Property | Type | Description
| --- | --- | ---
| handler | String | The type of edit this is. One of: `edit`, `remove`

#### draw:editstop

Triggered when the user has finshed editing (edit or remove mode) and saves edits.

| Property | Type | Description
| --- | --- | ---
| handler | String | The type of edit this is. One of: `edit`, `remove`

<a name="options" />
## Advanced options

Expand Down
2 changes: 2 additions & 0 deletions src/edit/handler/EditToolbar.Delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ L.EditToolbar.Delete = L.Handler.extend({
.on('layerremove', this._disableLayerDelete, this);

this.fire('enabled', { handler: this.type});
this._map.fire('draw:editstart', { handler: this.type });
},

disable: function () {
Expand All @@ -43,6 +44,7 @@ L.EditToolbar.Delete = L.Handler.extend({
.off('layerremove', this._disableLayerDelete, this);

this.fire('disabled', { handler: this.type});
this._map.fire('draw:editstop', { handler: this.type });
},

addHooks: function () {
Expand Down
4 changes: 3 additions & 1 deletion src/edit/handler/EditToolbar.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ L.EditToolbar.Edit = L.Handler.extend({
.on('layerremove', this._disableLayerEdit, this);

this.fire('enabled', {handler: this.type});
this._map.fire('draw:editstart', { handler: this.type });
},

disable: function () {
if (!this._enabled) { return; }

this.fire('disabled', {handler: this.type});
this._map.fire('draw:editstop', { handler: this.type });

this._featureGroup
.off('layeradd', this._enableLayerEdit, this)
Expand Down Expand Up @@ -233,4 +235,4 @@ L.EditToolbar.Edit = L.Handler.extend({
_onMouseMove: function (e) {
this._tooltip.updatePosition(e.latlng);
}
});
});

0 comments on commit 652c211

Please sign in to comment.