Surface placement

View inWPFUWPFormsiOSAndroid
View on GitHub

Position graphics relative to a surface using different surface placement modes.

Image of surface placement

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

  1. Create a GraphicsOverlay for each placement mode, setting SceneProperties.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.
  2. Add graphics to the graphics overlay, GraphicsOverlayGraphics.Add(Graphic).
  3. Add each graphics overlay to the scene view by calling SceneView.GraphicsOverlays.Add(overlay).

Relevant API

  • Graphic
  • GraphicsOverlay
  • SceneProperties.SurfacePlacement
  • SceneProperties
  • 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

SurfacePlacements.xmlSurfacePlacements.cs
                                                                  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/SurfacePlacements">
    <Esri.ArcGISRuntime.UI.Controls.SceneView
        android:id="@+id/SceneView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/Toolbar"/>
    <android.support.constraint.ConstraintLayout
        android:id="@+id/Toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@+id/SceneView"
        app:layout_constraintBottom_toTopOf="@+id/radioGroup"
        android:padding="10dp">
        <TextView
            android:id="@+id/Label"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Z Value"/>
        <SeekBar
            android:id="@+id/Slider"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:min="0"
            android:max="140"
            android:progress="70"
            app:layout_constraintLeft_toRightOf="@+id/Label"
            app:layout_constraintRight_toLeftOf="@+id/ValueLabel"/>
        <TextView
            android:id="@+id/ValueLabel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="70 meters"
            app:layout_constraintLeft_toRightOf="@+id/Slider"
            app:layout_constraintRight_toRightOf="parent"/>
    </android.support.constraint.ConstraintLayout>
    <RadioGroup
        android:id="@+id/radioGroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        android:orientation="horizontal" >
        <RadioButton
            android:id="@+id/billboardedButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Draped Billboarded"
            android:layout_weight="1"
            android:checked="true"/>
        <RadioButton
            android:id="@+id/flatButton"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:text="Draped Flat"
            android:layout_weight="1"/>
    </RadioGroup>
</android.support.constraint.ConstraintLayout>

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