Hello!
We are trying to calculate the distance/area of a user drawn graphic with the Sketch widget, which they've selected by clicking on the graphic on the map. However, it seems that the graphic is always an empty object.
The follow is a sample of what we have:
reactiveUtils.on(
() => mapView,
"click",
(event) => {
// graphicLayer is, you guessed it, a GraphicLayer
mapView?.hitTest(event, { include: graphicLayer }).then(function (response) {
const graphicHits = response.results?.filter(
(hitResult) => hitResult?.type === "graphic"
);
console.log(graphicHits);
if (graphicHits?.length > 0) {
// hitObj, currGraphic, and currMeasurements are initially defined
// somewhere else as null
hitObj = graphicHits?.at(0);
currGraphic = hitObj?.graphic;
console.log(currGraphic); // <- will always show a blank object
// simplyGeo just calls geometryEngine.simplify()
const simplified = simplifyGeo(currGraphic);
// creates an object with keys geodisc and planar that are
// assigned a value based on the results of
// geometryEngine.geodesicArea / geometryEngine.geodesicLength or
// geometryEngine.planarArea / geometryEngine.planarLength
// respectively
currMeasurements = getGraphicMeasurements(simplified);
}
});
}
);
Is there something else we have to do to get the graphic's data, instead of a blank object?