当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS SceneView.camera用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/views/SceneView"], (SceneView) => { /* code goes here */ });

ESM: import SceneView from "@arcgis/core/views/SceneView";

类: esri/views/SceneView

继承: SceneView > View > Accessor

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

SceneView.camera函数(或属性)的定义如下:

camera Camera autocast


确定SceneView 的可见部分(或透视图)的观察点。包含的属性包括当前视图的高程、倾斜和航向(以度为单位)。设置相机会立即更改当前视图。要为视图设置动画,请参阅 goTo()

在构造函数中设置时,此属性将覆盖视点、范围、中心、比例和缩放属性。

相机属性包含一个内部参考,将来可能会被修改。要保留或修改相机,请使用 camera.clone() 创建一个克隆。

在地理或公制坐标系中定义的Z-values 以米为单位。但是,在使用投影坐标系的局部场景中,假定垂直单位与服务指定的水平单位相同。

例子:

// Initializes the view at the given (x, y, z) position with a heading of 95 degrees.
// The position of the camera is a Point which will autocast in the sample
// below. Note that the default Point spatial reference is WGS84 which
// will only work if the SceneView has a Web Mercator or WGS84 spatial
// reference. For other spatial references, create a new position Point
// with an explicit spatial reference.
const view = new SceneView({
  camera: {
    position: [
       -122, // lon
         38, // lat
      50000  // elevation in meters
    ],

    heading: 95
  }
});
// Initializes the view at the given position with a tilt of 65 degrees
const view = new SceneView({
  camera: {
    position: {
      x: -100, // lon
      y: 45,   // lat
      z: 10654 // elevation in meters
    },

    tilt: 65
  }
});
// Clone the camera to modify its properties
const camera = view.camera.clone();

// Set new values for heading and tilt
camera.heading = 180;
camera.tilt = 45;

// Set the new properties on the view's camera
view.camera = camera;
// Set the view's camera to a new position, heading and tilt with the goTo() method
view.goTo({
  target: [-122, 38, 50000],
  heading: 180,
  tilt: 45
});

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 SceneView.camera。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。