Position graphics relative to a surface using different surface placement modes.
Use case
Depending on the use case, data might be displayed at an absolute height (e.g. flight data recorded with altitude information), at a relative height to the terrain (e.g. transmission lines positioned relative to the ground), at a relative height to objects in the scene (e.g. extruded polygons, integrated mesh scene layer), or draped directly onto the terrain (e.g. location markers, area boundaries).
How to use the sample
The application loads a scene showing four points that use individual surface placement modes (Absolute, Relative, Relative to Scene, and either Draped Billboarded or Draped Flat). Use the toggle to change the draped mode and the slider to dynamically adjust the Z value of the graphics. Explore the scene by zooming in/out and by panning around to observe the effects of the surface placement rules.
How it works
- Create a
GraphicsOverlay
for each placement mode, settingSceneProperties.SurfacePlacement
:Absolute
, position graphic using only its Z value.Relative
, position graphic using its Z value plus the elevation of the surface.DrapedBillboarded
, position graphic upright on the surface and always facing the camera, not using its z value.DrapedFlat
, position graphic flat on the surface, not using its z value.RelativeToScene
, position graphic using its Z value plus the altitude values of the scene.
- Add graphics to the graphics overlay,
GraphicsOverlayGraphics.Add(Graphic)
. - Add each graphics overlay to the scene view by calling
SceneView.GraphicsOverlays.Add(overlay)
.
Relevant API
- Graphic
- GraphicsOverlay
- SceneProperties
- SceneProperties.SurfacePlacement
- Surface
About the data
The scene launches with a view of Brest, France. Four points are shown hovering with positions defined by each of the different surface placement modes.
Additional information
This sample uses an elevation service to add elevation/terrain to the scene. Graphics are positioned relative to that surface for the DrapedBillboarded
, DrapedFlat
, and Relative
surface placement modes. It also uses a scene layer containing 3D models of buildings. Graphics are positioned relative to that scene layer for the RelativeToScene
surface placement mode.
Tags
3D, absolute, altitude, draped, elevation, floating, relative, scenes, sea level, surface placement
Sample Code
<UserControl x:Class="ArcGISRuntime.WPF.Samples.SurfacePlacements.SurfacePlacements"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:SceneView x:Name="MySceneView" />
<Border Width="175"
Height="auto"
Style="{StaticResource BorderStyle}">
<StackPanel>
<RadioButton x:Name="BillboardButton"
Content="Draped billboarded"
IsChecked="True" />
<RadioButton x:Name="FlatButton" Content="Draped flat" />
<Label Content="{Binding ElementName=ZSlider, Path=Value}" ContentStringFormat="Z-Value: {0:0} meters" />
<Slider x:Name="ZSlider"
Height="150"
Maximum="140"
Minimum="0"
Orientation="Vertical"
ValueChanged="ZValueChanged"
Value="70" />
</StackPanel>
</Border>
</Grid>
</UserControl>