Skip to content
import Circle from "@arcgis/core/geometry/Circle.js";
Inheritance:
CirclePolygonGeometryAccessor
Since
ArcGIS Maps SDK for JavaScript 4.0

A circle is a Polygon created by specifying a center point and a radius. The point can be provided as a Point object or an array of latitude/longitude values.

The SpatialReference of the center will determine the spatial reference of the circle. If you provide an array of longitude/latitude coordinates as the center, the spatial reference will default to WGS84 (wkid 4326). You cannot set the spatialReference property of the circle itself. It must always be set in the center point.

See also
Example
// Add a red circle to the map centered at -113°E, 36°N with a radius of 100 kilometers.
const circle = new Circle({
center: [-113, 36],
geodesic: true,
numberOfPoints: 100,
radius: 100,
radiusUnit: "kilometers"
});
view.graphics.add(new Graphic({
geometry: circle,
symbol: {
type: "simple-fill",
style: "none",
outline: {
width: 3,
color: "red"
}
}
}));

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
PropertyTypeClass
cache
readonly inherited
centroid
deprecated readonly inherited
curveRings
inherited
declaredClass
readonly inherited
extent
readonly inherited
hasM
inherited
hasZ
inherited
"feet" | "kilometers" | "meters" | "miles" | "nautical-miles" | "yards"
rings
inherited
number[][][]
spatialReference
inherited
type
readonly inherited
"polygon"

cache

readonlyinherited Property
Type
Record<string, any>
Inherited from: Geometry

The cache is used to store values computed from geometries that need to be cleared or recomputed upon mutation. An example is the extent of a polygon.

center

autocast Property
Type
Point | null | undefined

The center point of the circle. The center must be specified either as a Point or an array of longitude/latitude coordinates. The spatial reference of the center will determine the spatial reference of the circle. If you provide an array of longitude/latitude coordinates, the spatial reference will default to WGS84 (wkid 4326).

centroid

deprecatedreadonlyinherited Property
Type
Point | null | undefined
Inherited from: Polygon

The centroid of the polygon. For a polygon with multiple rings, it represents the centroid of the largest ring.

curveRings

inherited Property
Type
CurveJSON[][] | undefined
Inherited from: Polygon

An array consisting of points and curve objects that define the polygon geometry.

Example
// Polygon with a circular arc segment represented with a curve object.
const curvedPolygon = new Polygon({
curveRings: [
[
[-14008897.772168774,4219321.966491825],
{
c: [
[-13922799.120303603,4218343.568797498],
[-13964136.273597848,4258702.324397415]
]
},
[-13922799.120303603,4218343.568797498],
[-13923532.913909001,4170157.6736310786],
[-14010365.378040956,4170402.2683893144],
[-14008897.772168774,4219321.966491825]
]
],
spatialReference: { wkid: 102100 }
});

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

extent

readonlyinherited Property
Type
Extent | null | undefined
Inherited from: Geometry

The extent of the geometry. For a point, the extent is null.

geodesic

Property
Type
boolean

Applicable when the spatial reference of the center point is either set to Web Mercator (wkid: 3857) or geographic/geodesic (wkid: 4326). When either of those spatial references is used, set geodesic to true to minimize distortion. Other coordinate systems will not create geodesic circles.

Default value
false

hasM

inherited Property
Type
boolean
Inherited from: Geometry

Indicates if the geometry has M values.

Default value
false

hasZ

inherited Property
Type
boolean
Inherited from: Geometry

Indicates if the geometry has z-values (elevation).

Z-values defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service.

Default value
false

numberOfPoints

Property
Type
number

This value defines the number of points along the curve of the circle.

Default value
60

radius

Property
Type
number

The radius of the circle.

Default value
1000

radiusUnit

Property
Type
"feet" | "kilometers" | "meters" | "miles" | "nautical-miles" | "yards"

Unit of the radius.

Default value
"meters"

rings

inherited Property
Type
number[][][]
Inherited from: Polygon

An array of rings. Each ring is a two-dimensional array of numbers representing the coordinates of each vertex in the ring in the spatial reference of the view. The first vertex of each ring should always be the same as the last vertex. Each vertex is an array of two, three, or four numbers. The table below shows the various structures of a vertex array.

CaseVertex array
without z and without m[x, y]
without z and with m[x, y, m]
with z and without m[x, y, z]
with z and with m[x, y, z, m]
Example
//3D polygon rings with m-values (note that the second ring does not have m-values defined for it)
const rings = [
[ // first ring
[-97.06138,32.837,35.1,4.8],
[-97.06133,32.836,35.2,4.1],
[-97.06124,32.834,35.3,4.2],
[-97.06138,32.837,35.1,4.8] // same as first vertex
], [ // second ring
[-97.06326,32.759,35.4],
[-97.06298,32.755,35.5],
[-97.06153,32.749,35.6],
[-97.06326,32.759,35.4] // same as first vertex
]
];
const polygon = new Polygon({
hasZ: true,
hasM: true,
rings: rings,
spatialReference: { wkid: 4326 }
});

spatialReference

autocast inherited Property
Type
SpatialReference
Inherited from: Geometry

The spatial reference of the geometry.

Default value
SpatialReference.WGS84 // wkid: 4326

type

readonlyinherited Property
Type
"polygon"
Inherited from: Polygon

The string value representing the type of geometry.

Methods

MethodSignatureClass
fromExtent
inherited static
fromExtent(extent: Extent): Polygon
fromJSON
inherited static
fromJSON(json: any): any
addRing
inherited
addRing(points: number[][] | Point[]): this
clone(): Circle
contains
inherited
contains(point: Point): boolean
getPoint
inherited
getPoint(ringIndex: number, pointIndex: number): Point | null | undefined
insertPoint
inherited
insertPoint(ringIndex: number, pointIndex: number, point: Point | number[]): this
isClockwise
inherited
isClockwise(ring: number[][] | Point[]): boolean
removePoint
inherited
removePoint(ringIndex: number, pointIndex: number): Point | null | undefined
removeRing
inherited
removeRing(index: number): Point[] | null | undefined
setPoint
inherited
setPoint(ringIndex: number, pointIndex: number, point: Point | number[]): this
toJSON
inherited
toJSON(): any

fromExtent

inheritedstatic Method
Signature
fromExtent (extent: Extent): Polygon
Inherited from: Polygon

Converts the given Extent to a Polygon instance. This is useful for scenarios in which you would like to display an area of interest, which is typically defined by an Extent or bounding box, as a polygon with a fill symbol in the view. Some geoprocessing tools require input geometries to be of a Polygon type and not an Extent.

Parameters
ParameterTypeDescriptionRequired
extent

An extent object to convert to a polygon.

Returns
Polygon

A polygon instance representing the given extent.

Example
view.on("click", function(evt) {
const area = Polygon.fromExtent(view.extent);
const graphic = new Graphic({
geometry: area,
symbol: { type: "simple-fill" }
});
view.graphics.add(graphic);
});

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameters
ParameterTypeDescriptionRequired
json
any

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
any

Returns a new instance of this class.

addRing

inherited Method
Signature
addRing (points: number[][] | Point[]): this
Inherited from: Polygon

Adds a ring to the Polygon. The ring can be one of the following: an array of numbers or an array of points. When added the index of the ring is incremented by one.

Parameters
ParameterTypeDescriptionRequired
points
number[][] | Point[]

A polygon ring. The first and last coordinates/points in the ring must be the same. This can either be defined as an array of Point geometries or an array of XY coordinates.

Returns
this

Returns the polygon with the new ring included.

clone

Method
Signature
clone (): Circle

Creates a deep clone of Circle.

Returns
Circle

A new instance of a Circle object equal to the object used to call .clone().

contains

inherited Method
Signature
contains (point: Point): boolean
Inherited from: Polygon

Checks on the client if the input point is inside the polygon. A point on the polygon line is considered inside.

Parameters
ParameterTypeDescriptionRequired
point

The point to test whether it is contained within the testing polygon.

Returns
boolean

Returns true if the point is located inside the polygon.

getPoint

inherited Method
Signature
getPoint (ringIndex: number, pointIndex: number): Point | null | undefined
Inherited from: Polygon

Returns a point specified by a ring and point in the path.

Parameters
ParameterTypeDescriptionRequired
ringIndex

The index of the ring containing the desired point.

pointIndex

The index of the desired point within the ring.

Returns
Point | null | undefined

Returns the point at the specified ring index and point index.

insertPoint

inherited Method
Signature
insertPoint (ringIndex: number, pointIndex: number, point: Point | number[]): this
Inherited from: Polygon

Inserts a new point into the polygon.

Parameters
ParameterTypeDescriptionRequired
ringIndex

The index of the ring in which to insert the point.

pointIndex

The index of the point to insert within the ring.

point

The point to insert.

Returns
this

Returns the updated polygon.

isClockwise

inherited Method
Signature
isClockwise (ring: number[][] | Point[]): boolean
Inherited from: Polygon

Checks if a Polygon ring is clockwise.

Parameters
ParameterTypeDescriptionRequired
ring
number[][] | Point[]

A polygon ring. It can either be defined as an array of Point geometries or an array of XY coordinates.

Returns
boolean

Returns true if the ring is clockwise and false for counterclockwise.

removePoint

inherited Method
Signature
removePoint (ringIndex: number, pointIndex: number): Point | null | undefined
Inherited from: Polygon

Removes a point from the polygon at the given pointIndex within the ring identified by ringIndex.

Parameters
ParameterTypeDescriptionRequired
ringIndex

The index of the ring containing the point to remove.

pointIndex

The index of the point to remove within the ring.

Returns
Point | null | undefined

Returns the geometry of the removed point.

removeRing

inherited Method
Signature
removeRing (index: number): Point[] | null | undefined
Inherited from: Polygon

Removes a ring from the Polygon. The index specifies which ring to remove.

Parameters
ParameterTypeDescriptionRequired
index

The index of the ring to remove.

Returns
Point[] | null | undefined

Returns array of points representing the removed ring.

setPoint

inherited Method
Signature
setPoint (ringIndex: number, pointIndex: number, point: Point | number[]): this
Inherited from: Polygon

Updates a point in the polygon.

Parameters
ParameterTypeDescriptionRequired
ringIndex

The index of the ring containing the point to update.

pointIndex

The index of the point to update within the ring.

point

The new point geometry.

Returns
this

Returns the updated polygon.

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
any

The ArcGIS portal JSON representation of an instance of this class.