I am trying to set the extent for my ArcGIS map using the JavaScript API built in. Here's my code:
const [Extent] = await loadModules(["esri/geometry/Extent"]);
let response = new Extent();
for (const datum of dataPoints) {
let resExtent = new Extent(
datum.latitude,
datum.longitude,
datum.latitude,
datum.longitude,
response.spatialReference
);
response = await response.union(resExtent);
}
viewRef.current.goTo(response);
And my datum list is an array of coordinates such as: [..., {latitude: XXX, longitude: XXX}, ...]
. The above code plots the coordinates on the map but the extent is not correct with issues like some points lie in the boundary of the map.
How can I resolve this issue ?