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); }
I have managed to discover that this is a conflict between the api and 3rd party js.
remove the geoxml3.js script and it works
add it and it fails
The problem still occurs in version 3.24, using geodesicBuffer this time (see also attached image). I am not using third party modules. The fix appears to be the same:
Look for (note that this was wrapped over two lines in my text editor):
if(this.Pc||1E4<u.Ds&&1<u.Pj.length)
Replace with:
if((u)&&(this.Pc||1E4<u.Ds&&1<u.Pj.length))
Windows 10, IE 11
Parameters for geodesicBuffer:
geometry (string representation; an actual Polygon instance was passed):
"{"rings":[[[-17579866.91,2431821.3332],[-17579898.065899998,2431640.692400001],[-17579953.4001,2431648.533399999],[-17579955.833,2431635.3517999984],[-17580002.9127,2431644.161800001],[-17580004.8609,2431633.4224999994],[-17580024.7616,2431635.3834000006],[-17580029.1474,2431599.7437999993],[-17580055.357,2431604.640299998],[-17580035.3918,2431736.4585999995],[-17580027.1143,2431788.6972999982],[-17580007.9076,2431902.6317999996],[-17579983.056,2431899.3718999997],[-17579989.3852,2431863.747299999],[-17579983.7298,2431862.969900001],[-17579984.853,2431854.5929999985],[-17579920.7811,2431844.3082999997],[-17579922.2447,2431830.1493999995],[-17579866.91,2431821.3332]]],"spatialReference":{"wkid":102100,"latestWkid":3857}}"
distance: 500
unit: 9002
unionResults: false
To reiterate a response from nearly two years ago, this issue can be vetted and resolved more quickly when reported through Esri's technical support group. If not reported there it may never be looked at in a timely manner. Call support and provide details regarding the problem with your apps, and they will take more time than the JS team can allot to reproduce the issue and log it as a bug.