From 44599d6d3c5ae7d71fd391b3ab7ab179604ef7ea Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 1 May 2017 11:31:20 -0400 Subject: [PATCH] Fix throwing an error when drawing rectangle annotations. Fixes #692. --- src/annotation.js | 1 + tests/cases/annotation.js | 4 ++++ tests/cases/annotationLayer.js | 2 ++ 3 files changed, 7 insertions(+) diff --git a/src/annotation.js b/src/annotation.js index 62bb8078cc..febfcf1c2a 100644 --- a/src/annotation.js +++ b/src/annotation.js @@ -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; } diff --git a/tests/cases/annotation.js b/tests/cases/annotation.js index 557178ad76..c768c7bde9 100644 --- a/tests/cases/annotation.js +++ b/tests/cases/annotation.js @@ -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(); diff --git a/tests/cases/annotationLayer.js b/tests/cases/annotationLayer.js index e1be239bd1..cfa09a530a 100644 --- a/tests/cases/annotationLayer.js +++ b/tests/cases/annotationLayer.js @@ -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}, @@ -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}