fix: Guard converting an empty polygon.
MODIFY
examples/annotations/main.js
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();
}

MODIFY
src/annotation/annotation.js
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() : (

MODIFY
src/annotation/polygonAnnotation.js
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])]];

MODIFY
src/object.js
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.
*/

fix: Guard converting an empty polygon.