AMD:
require(["esri/geometry/operators/centroidOperator"], (centroidOperator) => { /* code goes here */ });
ESM:
import * as centroidOperator from "@arcgis/core/geometry/operators/centroidOperator.js";
Object:
esri/geometry/operators/centroidOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta
Calculates the centroid for a 2D geometry.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Performs the centroid operation on a geometry. | centroidOperator |
Method Details
-
execute
execute(geometry){Point}
-
Performs the centroid operation on a geometry.
Parametergeometry GeometryThe geometry in which to calculate the centroid.
ReturnsType Description Point The centroid of the geometry. Example// Return the centroid of a polygon const centroid = operatorCentroid.execute(polygon); console.log(`x: ${centroid.x}, y: ${centroid.y}`);