gisAPI文档(未完待续)

112 阅读4分钟

1. sceneView(三维视图)

1 goto()(相机位置或漫游)

esri/views/SceneView.goTo函数(或属性)的定义如下:

`goTo(target, options) ``````{Promise}```````

将视图设置为给定目标。目标参数可以是以下之一:

  • [longitude, latitude] 坐标对
  • Geometry(或 Geometry[] 的数组)
  • Graphic(或 Graphic[] 的数组)
  • Viewpoint
  • Camera
  • 具有 targetcenterscalepositionheadingtilt 属性组合的对象(target 是上面列出的任何类型)。提供 center 属性是为了方便为 SceneView.center 设置动画,它等效于指定带有中心 Pointtarget。必须在视图的空间参考中提供目标。

此函数返回一个承诺,一旦新视图设置为目标,该承诺就会解决。如果过渡是动画的,则可以使用 SceneView.animation 获得正在进行的动画。如果将视图设置为新目标失败,则 goTo() 方法返回的承诺将拒绝并出现错误。使用 catch 语句来处理错误:

view.goTo({
  center: [-126, 49]
})
.catch(function(error) {
  if (error.name != "AbortError") {
     console.error(error);
  }
});

如果给定目标远离当前相机位置,则航向和倾斜将自动设置为其中性值(面向北方,自上而下)。始终可以显式设置倾斜和航向以覆盖此行为。

参数:

类型说明
target GoToTarget3D要前往的目标位置/视点。为 target 使用对象时,请使用 GoToTarget3D 中定义的属性。
options GoToOptions3D可选的 查看过渡选项。有关详细信息,请参阅GoToOptions3D 中定义的规范

options

  • 属性

animateBoolean

Default Value:true

指示是否应动画切换到新视图。如果设置为false,则会忽略speedFactor、duration、maxDuration和easing属性。

speedFactorNumber

Default Value:1

按指定的系数增加或减少动画速度。speedFactor为2将使动画速度加倍,而speedFactor0.5将使动画的速度减半。设置速度系数将相应地自动调整默 认的maxDuration。

durationNumber

Default Value:8000

动画允许的最大持续时间(毫秒)。默认的maxDuration值会考虑指定的speedFactor。

easingString|EasingFunction

用于动画的easing函数。这可以是预设(命名)函数,也可以是用户指定的函数。支持的命名预设为:线性、in-cubit、out-cubic、in-out-cubid、in-expo、 out-expo和in-out-expo,in-out-soast二次方。有关这些函数的图形表示,请参见简化函数。

默认情况下,小于1000毫秒的动画使用out-expo easing功能;较长的动画使用海岸内外二次松弛函数。

signal

An AbortSignal to abort the animation. If canceled, the promise will be rejected with an error named AbortError. See also AbortController.

中止动画的中止信号。如果取消,承诺将被拒绝,错误名为AbortError。也看到AbortController。

返回:

类型说明
Promise当视图的范围更新到 target 中定义的范围时解决的承诺

例子:

view.goTo({
  center: [-126, 49],
  heading: 180, // set the heading to point South
  tilt: view.camera.tilt, // maintain tilt value
});
// go to a location defined by a Camera object
let cam = new Camera({
  position: new Point({
    x: -100.23, // lon
    y: 65,      // lat
    z: 10000,   // elevation in meters
  }),
​
  heading: 180, // facing due south
  tilt: 45      // bird's eye view
});
​
view.goTo(cam);
// go to a point using center, zoom, tilt, and heading
view.goTo({
  center: [-126, 49],
  zoom: 13,
  tilt: 75,
  heading: 105
});
// goTo returns a Promise which resolves when the animation has finished.
// This promise may be chained to create a sequence of animations.
view.goTo(graphic1)
    .then(function() {
      return view.goTo(graphic2);
    })
    .then(function() {
      return view.goTo(graphic3);
    });
// goTo returns a Promise which resolves when the animation has finished.
// This promise may be chained to create a sequence of animations.
view.goTo(graphic1)
    .then(function() {
      return view.goTo(graphic2);
    })
    .then(function() {
      return view.goTo(graphic3);
    });

2.Map(底图)

1.map.add() 添加图层

向图层集合中添加一个图层。在调用此方法时,将触发更改前、添加前、添加后、更改后和更改事件。

  • 参数
layer(layer或promise)层或承诺,解析为一个层添加到层集合
index (Number)可选的 可以在图层集合的指定索引处添加图层。如果没有指定索引或指定的索引大于当前层数,则自动将该层添加到layers集合中的层列表中,并将索引归一化。

例子:

// add() and push methods can be used
// to add a layer to layers collection// add a layer to layers collection using add
map.add(layer);
​
// add a layer at the end of layers collection
map.layers.push(layer);

2.map.remove() 删除图层

从layers集合中移除指定的层。当调用此方法时,将触发更改前、删除前、删除后、更改后和更改事件。

  • 参数
layer从图层集合中删除

Returns:

TypeDescription
Layer返回从layers集合中移除的图层。

\