Elevation options

This sample shows how to change the elevation information of a 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:

elevation-info-modes
  • on-the-ground: Balloon 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: Balloon 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: Balloon graphics are placed at an elevation relative to buildings. If present, the geometry's z-value is added to the elevation. If featureExpressionInfo is defined, the result of the expression is used instead of the geometry’s z-value.

    Relative to the scene
  • absolute-height: Balloon 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, zvalues 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:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
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.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.