ESM: import Polygon from "@arcgis/core/geometry/Polygon.js";
CDN: const Polygon = await $arcgis.import("@arcgis/core/geometry/Polygon.js");
Class: @arcgis/core/geometry/Polygon
Since: ArcGIS Maps SDK for JavaScript 4.0
Property Overview Any properties can be set, retrieved or listened to. See the Watch for changes topic.Show inherited properties Hide inherited properties
Property DetailsInherited
Property cache Objectreadonly
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.
The centroid of the polygon. For a polygon with multiple rings, it represents the centroid of the largest ring.
Inherited
Property declaredClass Stringreadonly
Since: ArcGIS Maps SDK for JavaScript 4.7 Accessor since 4.0, declaredClass added at 4.7.
The name of the class. The declared class name is formatted as esri.folder.className
.
The extent of the geometry. For a point, the extent is null.
Inherited
Property hasM Boolean
Indicates if the geometry has M values.
Inherited
Property hasZ Boolean
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.
isSelfIntersecting Booleanreadonly
Checks to see if polygon rings cross each other and indicates if the polygon is self-intersecting, which means the ring of the polygon crosses itself.
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.
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 }
});
The spatial reference of the geometry.
Default Value:SpatialReference.WGS84 // wkid: 4326
type Stringreadonly
The string value representing the type of geometry.
For Polygon the type is always "polygon".
Show inherited methods Hide inherited methods
Method DetailsInherited
Method addHandles(handleOrHandles, groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles
const handle = reactiveUtils.when(
() => !view.updating,
() => {
wkidSelect.disabled = false;
},
{ once: true }
);
this.addHandles(handle);
// Destroy the object
this.destroy();
Parameters
Handles marked for removal once the object is destroyed.
groupKey *
optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
addRing(points){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.
Parameter
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
Type Description Polygon Returns the polygon with the new ring included.Creates a deep clone of Polygon object.
Returns
Type Description Polygon A new instance of a Polygon object equal to the object used to call.clone()
.
contains(point){Boolean}
Checks on the client if the input point is inside the polygon. A point on the polygon line is considered inside.
Parameter
The point to test whether it is contained within the testing polygon.
Returns
Type Description Boolean Returnstrue
if the point is located inside the polygon.
fromExtent(extent){Polygon}static
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.
Parameter
An extent object to convert to a polygon.
Returns
Type Description 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);
});
Inherited
Method fromJSON(json){* |null |undefined}static
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.
Returns
Type Description * | null | undefined Returns a new instance of this class.Returns a point specified by a ring and point in the path.
Parameters
The index of the ring containing the desired point.
The index of the desired point within the ring.
Returns
Type Description Point | null | undefined Returns the point at the specified ring index and point index.Inherited
Method hasHandles(groupKey){Boolean}
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.
Returns true if a named group of handles exist.
Parameter
groupKey *
optionalA group key.
Returns
Type Description Boolean Returnstrue
if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
obj.removeHandles("watch-view-updates");
}
insertPoint(ringIndex, pointIndex, point){Polygon}
Inserts a new point into the polygon.
Parameters
The index of the ring in which to insert the point.
The index of the point to insert within the ring.
The point to insert.
Returns
Type Description Polygon Returns the updated polygon. isClockwise(ring){Boolean}
Checks if a Polygon ring is clockwise.
Parameter
A polygon ring. It can either be defined as an array of Point geometries or an array of XY coordinates.
Returns
Type Description Boolean Returnstrue
if the ring is clockwise and false
for counterclockwise.
Inherited
Method removeHandles(groupKey)
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.
Removes a group of handles owned by the object.
Parameter
groupKey *
optionalA group key or an array or collection of group keys to remove.
Example
obj.removeHandles(); // removes handles from default group
obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");
Removes a point from the polygon at the given pointIndex
within the ring identified by ringIndex
.
Parameters
The index of the ring containing the point to remove.
The index of the point to remove within the ring.
Returns
Removes a ring from the Polygon. The index specifies which ring to remove.
Parameter
The index of the ring to remove.
Returns
setPoint(ringIndex, pointIndex, point){Polygon}
Updates a point in the polygon.
Parameters
The index of the ring containing the point to update.
The index of the point to update within the ring.
The new point geometry.
Returns
Type Description Polygon Returns the updated polygon.RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4