Fix throwing an error when drawing rectangle annotations.
Fixes
MODIFY
src/annotation.js
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;
}

MODIFY
tests/cases/annotation.js
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();

MODIFY
tests/cases/annotationLayer.js
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}

Fix throwing an error when drawing rectangle annotations.

Fixes #692.