Skip to content

Commit

Permalink
Merge pull request #693 from OpenGeoscience/fix-rectangle-error
Browse files Browse the repository at this point in the history
Fix throwing an error when drawing rectangle annotations.
  • Loading branch information
manthey authored May 1, 2017
2 parents 44fb403 + 44599d6 commit 6aefc25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ var rectangleAnnotation = function (args) {
this.processAction = function (evt) {
var layer = this.layer();
if (this.state() !== annotationState.create || !layer ||
evt.event !== geo_event.actionselection ||
evt.state.action !== geo_action.annotation_rectangle) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/cases/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,14 @@ describe('geo.annotation', function () {
expect(ann.processAction({state: null})).toBe(undefined);
ann.state(geo.annotation.state.create);
var evt = {
event: geo.event.actionmove,
state: {action: geo.geo_action.annotation_rectangle},
lowerLeft: {x: 10, y: 65},
upperRight: {x: 90, y: 5}
};
expect(ann.processAction(evt)).not.toBe('done');
expect(ann.state()).toBe(geo.annotation.state.create);
evt.event = geo.event.actionselection;
expect(ann.processAction(evt)).toBe('done');
expect(ann.state()).toBe(geo.annotation.state.done);
var coor = ann.coordinates();
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/annotationLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ describe('geo.annotationLayer', function () {
it('_processAction', function () {
layer.removeAllAnnotations();
layer._processAction({
event: geo.event.actionselection,
state: {action: geo.geo_action.annotation_rectangle},
lowerLeft: {x: 10, y: 10},
lowerRight: {x: 20, y: 10},
Expand All @@ -395,6 +396,7 @@ describe('geo.annotationLayer', function () {
layer.mode('rectangle');
expect(layer.annotations()[0].state()).toBe(geo.annotation.state.create);
layer._processAction({
event: geo.event.actionselection,
state: {
action: geo.geo_action.annotation_rectangle,
actionRecord: {owner: geo.annotation.actionOwner}
Expand Down

0 comments on commit 6aefc25

Please sign in to comment.