geometry

require(["esri/geometry"], function(geometry) { /* code goes here */ });
Object: esri/geometry
Since: ArcGIS API for JavaScript 4.6

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 = require("esri/geometry/Point");
import Polygon = require("esri/geometry/Polygon");
import Polyline = require("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 { Geometry } from "esri/geometry";

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.")
  }
}

API Reference search results

NameTypeModule
Loading...