Skip to content

Commit

Permalink
Fix rectangle annotations to conform to new GeoJS interface
Browse files Browse the repository at this point in the history
OpenGeoscience/geojs#623 was resolved and #51
implicitly upgraded our version to incorporate the new interface. As a
result, trying to make a rectangle annotation threw a
"JSONRPCError (-32000): list index out of range".
  • Loading branch information
danlamanna committed Dec 12, 2016
1 parent 9564236 commit b2125d9
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions js/src/MapObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,9 @@ MapObject.prototype.add_annotation = function (annotation) {
this.rpc_error.bind(this));
};

// Note: point/polygon's fire 'state' when they are added to
// the map, while rectangle's fire 'add'
// See: https://github.com/OpenGeoscience/geojs/issues/623
MapObject.prototype.add_annotation_handler = function (evt) {
var annotation = evt.annotation;
if (annotation.type() === 'rectangle') {
this.add_annotation(annotation);
}
};
MapObject.prototype.state_annotation_handler = function (evt) {
var annotation = evt.annotation;
if (annotation.type() === 'point' || annotation.type() === 'polygon') {
if (_.contains(['point', 'polygon', 'rectangle'], annotation.type())) {
this.add_annotation(annotation);
}
};
Expand All @@ -152,7 +143,6 @@ MapObject.prototype.add_annotation_layer = function (layer_name, params) {
});
layer.name(layer_name);

layer.geoOn(geo_event.annotation.add, this.add_annotation_handler.bind(this));
// layer.geoOn(geo_event.annotation.remove, handleAnnotationChange);
layer.geoOn(geo_event.annotation.state, this.state_annotation_handler.bind(this));

Expand Down

0 comments on commit b2125d9

Please sign in to comment.