Elevation options

Loading...

Note: Support for 3D on mobile devices may vary, view the system requirements for more information.

This sample shows how to change the elevation information of a 2D FeatureLayer for 3D visualization. Various options are available to customize the elevation of features in a 3D scene by modifying the elevationInfo property of a FeatureLayer.

Four properties allow you to customize each feature's elevation: mode, offset, featureExpressionInfo and unit.

Elevation mode sets the type of elevation placement. These are the values that mode can take:

  • on-the-ground: Graphics are draped on the terrain surface. In this mode offset, featureExpressionInfo, and unit have no effect and z values are discarded.
On the ground
  • relative-to-ground: Graphics are placed at an elevation relative to the terrain surface. If graphics have z values, they will be kept. If defined, featureExpressionInfo is used instead of z values. In the screenshot below, the graphics have z values, but we set the expression in featureExpressionInfo to 0.
Relative to the ground
  • relative-to-scene: Graphics are placed at an elevation relative to buildings. In this mode, z values are discarded, but featureExpressionInfo is considered if defined.
Relative to the scene
  • absolute-height: Graphics are placed at an absolute height relative to the datum. The absolute height is determined by each feature's z value. This mode works like relative-to-ground with the difference that terrain elevation is discarded.

Graphic offset is added to the elevation of all graphics. An offset of 100 moves the symbols 100 units (meters by default) above their existing elevation. Changing the unit to kilometers places the graphics 100km above the ground as shown in the image below:

offset

(z values are here not considered because featureExpressionInfo is defined)

Custom elevation can be calculated using featureExpressionInfo, which is an Arcade expression that evaluates to a custom elevation value. Once this property is set, z values are not considered anymore.

For example, you can do the following to calculate a custom elevation based on a feature's z value and an attribute:

elevationInfo: {
  mode: "relative-to-ground",
  featureExpressionInfo: {
    expression: "Geometry($feature).z * 10 + $feature.HEIGHT100"
  },
  unit: "meters"
}

This is how the graphics would be elevated using this code:

custom-elevation

outFields should be defined on the layer when using attributes in expression.

Elevation unit defines the units for featureExpressionInfo and offset. By default it is meters.

Compare this sample to 3D symbols for points to understand the different choices of visualizing 2D features in 3D.

Sample search results

TitleSample
Loading...