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
Calculates the centroid for a 2D geometry.
Property Overview
Name | Type | Summary | Object |
---|---|---|---|
Indicates if the operator supports input geometries that contain curves. | centroidOperator |
Property Details
-
supportsCurves
supportsCurves Booleanreadonly
-
Indicates if the operator supports input geometries that contain curves.
- Default Value:true
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 GeometryUnionThe 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}`);