Scene properties expressions

View inWPFWinUIUWPFormsiOSAndroid
View on GitHub

Update the orientation of a graphic using expressions based on its attributes.

Image of scene properties expressions

Use case

Instead of reading the attribute and changing the rotation on the symbol for a single graphic (a manual CPU operation), you can bind the rotation to an expression that applies to the whole overlay (an automatic GPU operation). This usually results in a noticeable performance boost (smooth rotations).

How to use the sample

Adjust the heading and pitch sliders to rotate the cone.

How it works

  1. Create a new graphics overlay.
  2. Create a simple renderer and set its scene properties.
  3. Set the heading expression to [HEADING].
  4. Apply the renderer to the graphics overlay.
  5. Create a graphic and add it to the overlay.
  6. To update the graphic's rotation, update the HEADING or PITCH property in the graphic's attributes.

Relevant API

  • Graphic.Attributes
  • GraphicsOverlay
  • SceneProperties
  • SceneProperties.HeadingExpression
  • SceneProperties.PitchExpression
  • SimpleRenderer
  • SimpleRenderer.SceneProperties

Tags

3D, expression, graphics, heading, pitch, rotation, scene, symbology

Sample Code

ScenePropertiesExpressions.xamlScenePropertiesExpressions.xamlScenePropertiesExpressions.xaml.cs
Use dark colors for code blocksCopy
                                              
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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.ScenePropertiesExpressions.ScenePropertiesExpressions"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:resources="clr-namespace:Forms.Resources;assembly=ArcGISRuntime">
    <RelativeLayout>
        <esriUI:SceneView x:Name="MySceneView"
                          Style="{StaticResource MapWithFormStyle}"
                          ViewInsets="0" />
        <resources:ResponsiveFormContainer x:Name="FormContainer">
            <StackLayout>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="200" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Column="0"
                           Style="{StaticResource LabelStyle}"
                           Text="Heading:" />
                    <Slider x:Name="HeadingSlider"
                            Grid.Column="1"
                            Maximum="360"
                            MaximumTrackColor="CadetBlue"
                            Minimum="0"
                            MinimumTrackColor="CadetBlue" />
                </Grid>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="200" />
                    </Grid.ColumnDefinitions>
                    <Label Grid.Column="0"
                           Style="{StaticResource LabelStyle}"
                           Text="Pitch:" />
                    <Slider x:Name="PitchSlider"
                            Grid.Column="1"
                            Maximum="90"
                            MaximumTrackColor="CadetBlue"
                            Minimum="-90"
                            MinimumTrackColor="CadetBlue" />
                </Grid>
            </StackLayout>
        </resources:ResponsiveFormContainer>
    </RelativeLayout>
</ContentPage>

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