1

我是arcgis的新手。我试图以 3D 的特定角度显示特定位置。该位置位于宾夕法尼亚州麦基斯波特的水街和第五大道的拐角处。角度朝东。倾斜度为 45。但这就是我得到的:https ://codepen.io/lschneiderman/pen/ZEQEWXG

我的代码如下:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>ArcGIS JavaScript Tutorials: Create a JavaScript starter app</title>
    <style>
      html, body, #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>
    <link rel="stylesheet" href="https://js.arcgis.com/4.15/esri/themes/light/main.css">
      <script src="https://js.arcgis.com/4.15/"></script>
  </head>
  <body>
    <div id="viewDiv"></div>

    <script>
        require([
              "esri/Map",
              "esri/views/SceneView"
            ], function(Map, SceneView) {

            var map = new Map({
              basemap: "topo-vector",
              ground: "world-elevation"  // show elevation
            });

            var view = new SceneView({
              container: "viewDiv",
              map: map,
                heading: 90,
              camera: {
                position: {  // observation point
                  latitude: '40.350500',
                  longitude: '-79.868870',
                  z: 1000  // altitude in meters
                },
                tilt: 45  // perspective in degrees
              }
            });
          });
    </script>
  </body>
</html>
4

1 回答 1

1

camera确保在对象上设置查看方向的航向(角度) 。这将使相机向东看,位于十字路口上方

var view = new SceneView({
  container: "viewDiv",
  map: map,
  camera: {
    position: {
      // observation point
      latitude: "40.350500",
      longitude: "-79.868870",
      z: 700 // altitude in meters// altitude in meters
    },
    heading: 90,
    tilt: 45 // perspective in degrees
  }
});

这是修改后的 CodePen 的链接:https ://codepen.io/arnofiva/pen/688eee67141131712a12ccc3310a6ea4?editors=1010

如果你想让相机看十字路口,你需要通过向东移动相机来采用该位置,例如:

latitude: "40.350464",
longitude: "-79.874628",

这是另一个版本的 CodePen,它显示了相机视野中的交叉点: https ://codepen.io/arnofiva/pen/a2da1acb4cba398721690bf4d0b2101a?editors=0010


而不是手动设置这些值,它可能更容易使用SceneView.goTo()并将您希望它关注的点作为参数传递:

var view = new SceneView({
  container: "viewDiv",
  map: map
});

view.goTo({
  target: [-79.86887, 40.3505], // coordinates of crossing
  heading: 90,
  tilt: 45,
  zoom: 18 // instead of a z-value, we provide the zoom level
}, {
  duration: 0 // tell view not to animate camera movement
});

这是显示使用的 CodePen goTo()https ://codepen.io/arnofiva/pen/e91dd1b257a002a0c4d007d3724e039f?editors=1010

于 2020-06-02T21:38:31.777 回答