containsOperator

AMD: require(["esri/geometry/operators/containsOperator"], (containsOperator) => { /* code goes here */ });
ESM: import * as containsOperator from "@arcgis/core/geometry/operators/containsOperator.js";
Object: esri/geometry/operators/containsOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

Performs a relational operation to determine if one 2D geometry contains another 2D geometry. Geometry A contains geometry B, when B is the intersection of A and B. A contains B is equivalent to B within A. Geometry B can be non-simple geometry.

Method Overview

Name Return Type Summary Object

Accelerate a geometry.

containsOperator

Perform the contains operation on two geometries.

containsOperator

Method Details

accelerateGeometry

Method
accelerateGeometry(geometry){Boolean}

Accelerate a geometry. This method prepares the geometry for faster contains operations when the same geometry is tested multiple times (e.g. in a loop with hundreds of iterations).

Parameter
geometry Geometry

The geometry to accelerate.

Returns
Type Description
Boolean Returns true if the geometry was successfully accelerated.

execute

Method
execute(geometry1, geometry2){Boolean}

Perform the contains operation on two geometries.

Parameters
geometry1 Geometry

The geometry that is tested for the "contains" relationship to geometry2.

geometry2 Geometry

The geometry that is tested for the "within" relationship to geometry1.

Returns
Type Description
Boolean Returns true if geometry1 contains geometry2.
Example
// Returns true if one geometry contains another
const isContained = containsOperator.execute(polygon1, polygon2);

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.