geometry

AMD: require(["geoscene/geometry"], (geometry) => { /* code goes here */ });
ESM: import * as geometry from "@geoscene/core/geometry";
类: geoscene/geometry
起始版本:GeoScene Maps SDK for JavaScript 4.6

使用 TypeScript 开发时,导入 Geometry 类的便捷模块。例如,不是像这样一次导入多个几何:

import Point from "geoscene/geometry/Point";
import Polygon from "geoscene/geometry/Polygon";
import Polyline from "geoscene/geometry/Polyline";

您可以使用此模块在一行中导入它们:

import { Point, Polygon, Polyline } from "geoscene/geometry";

此模块还允许您在几何上实现类型保护,从而使代码更加智能。

import { Geometry } from "geoscene/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.")
  }
}

您的浏览器不再受支持。请升级您的浏览器以获得最佳体验。请参阅浏览器弃用帖子以获取更多信息