I have tried the GeometryEngine.union method (within JavaScript 3.15 API) but it throws the following error when it is placed within a try-catch statement:
TypeError: Unable to get property 'hq' of undefined or null reference
It seems to work when not placed within a try-catch, but since it is throwing this error I'm concerned about using it within a production application. Also, the equivalent Union method in the ArcGIS Server GeometryService does not throw an error.
I thought the error might be due to undefined spatial references in the array of geometries passed to it, but I have checked and they are all defined.
Can anyone please advise why this error is being thrown?
arrayUtils.forEach(AdviceGlobal.savedFeaturesGraphicsLayer.graphics, function (savedGraphic) {
// Define spatial reference for geometryEngine
var thisGeometry = savedGraphic.geometry;
console.log(thisGeometry.spatialReference);
if (thisGeometry.spatialReference == null) {
thisGeometry.spatialReference = map.spatialReference;
}
geometryToCapture.push(thisGeometry);
});
// Try geometryEngine
try {
var unionedGeometry = geometryEngine.union(geometryToCapture);
saveFeature(unionedGeometry);
}
catch (e) {
onUnionError(e);
}