require(["esri/geometry"], (geometry) => { /* code goes here */ });
import * as geometry from "@arcgis/core/geometry.js";
esri/geometry
A convenience module for importing Geometry classes when developing with TypeScript. For example, rather than importing geometries one at a time like this:
import Point from "esri/geometry/Point";
import Polygon from "esri/geometry/Polygon";
import Polyline from "esri/geometry/Polyline";
You can use this module to import them on a single line:
import { Point, Polygon, Polyline } from "esri/geometry";
This module also allows you to implement type guards on geometries, making your code smarter.
import { GeometryUnion } from "esri/unionTypes";
function logGeometry(geometry: Geometry): void {
if (geometry.type === "point") {
// new at 4.6, the compiler knows the geometry is a Point instance
console.log("point coords: ", geometry.x, geometry.y, geometry.z);
}
else {
// the compiler knows the geometry must be a `Extent | Polygon | Multipoint | Polyline`
console.log("The value is a geometry, but isn't a point.")
}
}
Type Definitions
-
Deprecated since version 4.32. Use GeometryUnion instead.
-
Geometry types.
-
Multipoint
Multipoint Multipoint
Deprecated since version 4.32. Import Multipoint directly instead. -
Multipoint.
-
SpatialReference
SpatialReference SpatialReference
Deprecated since version 4.32. Import SpatialReference directly instead. -
Spatial Reference.