At a certain user's choice, I draw the necessary polygons at the given coordinates from the given object and add them to the map in the form of graph figures. Then I want to show the selection on the map and use method GOTO. Polygons are added in a loop. I've already tried all sorts of ways. And zoomed in. And changed in a cycle. And after the cycle. And in the end, it's still kind of clumsy. That's not in the right place. Either too small or too large. If, for example, the United States, then it is not in the middle at all. How best to use To zoom the user on the map to the right place? Is there a better optimal solution? Has anyone encountered similar problems?
my code is something like this :
const map = new Map({
ground: "world-elevation",
basemap: grayBasemap
});
const view = new SceneView({
container,
map: map,
qualityProfile: "high",
zoom: 4
});
this.view.graphics.removeAll();
for (var i = 0; i < objCoordinates.length; i++) {
var coordinates = objCoordinates[0];
var polygon = new Polygon();
polygon.addRing(coordinates);
var polygonGraphic = new Graphic({
geometry: polygon,
symbol: fillSymbol
});
this.view.graphics.add(polygonGraphic);
}
this.view.goTo({
target: this.view.graphics
}).catch(this.catchAbortError);