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, feature and unit.
Elevation mode sets the type of elevation placement. These are the values that mode can take:
-
on-the-ground: Balloon graphics are draped on the terrain surface. In this modeoffset,feature, andExpression Info unithave no effect and z-values are discarded. -
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,featureis used instead of z-values.Expression Info -
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. Iffeatureis defined, the result of the expression is used instead of the geometry’s z-value.Expression Info -
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 likerelative-to-groundwith 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.
Custom elevation can be calculated using feature, 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"
}outFields should be defined on the layer when using attributes in expression.
Elevation unit defines the units for feature 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.