當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。