diff --git a/examples/annotations/main.js b/examples/annotations/main.js index b435d898b3..4b6098d280 100644 --- a/examples/annotations/main.js +++ b/examples/annotations/main.js @@ -212,7 +212,7 @@ function setBrushMode(mode) { const annot = geo.registries.annotations[shape].func({layer: layer}); brushLayer.addAnnotation(annot); annot._coordinates([{x: 0, y: 0}, {x: size, y: 0}, {x: size, y: size}, {y: size, x: 0}]); - brushLayer.mode('cursor', annot); + brushLayer.mode(brushLayer.modes.cursor, annot); map.draw(); } diff --git a/src/annotation/annotation.js b/src/annotation/annotation.js index 9b1d22537e..df0c3083d9 100644 --- a/src/annotation/annotation.js +++ b/src/annotation/annotation.js @@ -141,6 +141,9 @@ var annotation = function (type, args) { * Clean up any resources that the annotation is using. */ this._exit = function () { + if (m_this.layer()) { + m_this.layer().geoOff(geo_event.mousemove, m_this._cursorHandleMousemove); + } }; /** @@ -754,6 +757,9 @@ var annotation = function (type, args) { */ this.coordinates = function (gcs) { var coord = m_this._coordinates() || []; + if (!coord.length && (!coord.outer || !coord.outer.length)) { + coord = []; + } if (m_this.layer()) { var map = m_this.layer().map(); gcs = (gcs === null ? map.gcs() : ( diff --git a/src/annotation/polygonAnnotation.js b/src/annotation/polygonAnnotation.js index bc3b1c1be3..eca5c7e6c6 100644 --- a/src/annotation/polygonAnnotation.js +++ b/src/annotation/polygonAnnotation.js @@ -134,7 +134,7 @@ var polygonAnnotation = function (args) { (coord.inner || []).forEach((h) => result[0].push(h.map((pt) => [pt.x, pt.y]))); return result; } - if (coord.length < 3) { + if (coord.length < 3 || !coord.map) { return []; } return [[coord.map((pt) => [pt.x, pt.y])]]; diff --git a/src/object.js b/src/object.js index 08b3f1eb47..b1486706e3 100644 --- a/src/object.js +++ b/src/object.js @@ -273,6 +273,15 @@ var object = function () { return m_this; }; + /** + * Report the current event handlers. + * + * @returns {object} An object with all of the event handlers. + */ + this._eventHandlers = function () { + return m_eventHandlers; + }; + /** * Free all resources and destroy the object. */