Click or drag to resize

DistanceCompositeSceneSymbol Class

Defines a set of symbols and their visible distance range.
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class DistanceCompositeSceneSymbol : SceneSymbol

The DistanceCompositeSceneSymbol type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleDistanceCompositeSceneSymbol
Initializes a new instance of the DistanceCompositeSceneSymbol class.
Top
Properties
  NameDescription
Public propertyCode exampleRanges
Gets a mutable list of DistanceSymbolRange.
Top
Methods
  NameDescription
Public methodClone
Clones this instance of Symbol and its members.
(Inherited from Symbol.)
Public methodCode exampleCreateSwatchAsync(Double)
Creates a swatch image of this symbol using the default size and a transparent background.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Color, Double)
Creates a swatch image of this symbol, using the default sizing and a transparent background.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Int32, Int32, Double, Color)
Creates a swatch image of this symbol, scaled to fit the specified dimensions.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Int32, Int32, Single, Color, Geometry)
Creates a swatch image of this symbol, with the specified image size, dpi, background color, and geometry.
(Inherited from Symbol.)
Public methodToJson
Returns the json representation of the symbol
(Inherited from Symbol.)
Top
Events
  NameDescription
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from Symbol.)
Top
Examples

WPF

Example Name: UseDistanceCompositeSym

Change a graphic's symbol based on the camera's proximity to it.

Code example screen shot.

C#
// Copyright 2017 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Drawing;
using System.Threading.Tasks;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.UseDistanceCompositeSym
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Distance composite scene symbol",
        category: "Symbology",
        description: "Change a graphic's symbol based on the camera's proximity to it.",
        instructions: "The sample starts looking at a plane. Zoom out from the plane to see it turn into a cone. Keeping zooming out and it will turn into a point.",
        tags: new[] { "3D", "data", "graphic", "range", "symbol" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("681d6f7694644709a7c830ec57a2d72b")]
    public partial class UseDistanceCompositeSym
    {
        public UseDistanceCompositeSym()
        {
            InitializeComponent();

            // Create the Scene, basemap, graphic, and composite symbol.
            Initialize();
        }

        private async void Initialize()
        {
            try
            {
                // Create a new Scene with an imagery basemap.
                Scene myScene = new Scene(BasemapStyle.ArcGISImageryStandard);

                // Add the Scene to the SceneView.
                MySceneView.Scene = myScene;

                // Create a new GraphicsOverlay and add it to the SceneView.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                graphicsOverlay.SceneProperties.SurfacePlacement = SurfacePlacement.Relative;
                MySceneView.GraphicsOverlays.Add(graphicsOverlay);

                // Call a function to create a new distance composite symbol with three ranges.
                DistanceCompositeSceneSymbol compositeSymbol = await CreateCompositeSymbol();

                // Create a new point graphic with the composite symbol, add it to the graphics overlay.
                MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
                Graphic pointGraphic = new Graphic(locationPoint, compositeSymbol);
                graphicsOverlay.Graphics.Add(pointGraphic);

                // Add an orbit camera controller to lock the camera to the graphic.
                OrbitGeoElementCameraController cameraController = new OrbitGeoElementCameraController(pointGraphic, 20)
                {
                    CameraPitchOffset = 80,
                    CameraHeadingOffset = -30
                };
                MySceneView.CameraController = cameraController;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }

        private async Task<DistanceCompositeSceneSymbol> CreateCompositeSymbol()
        {
            // Get the path to the 3D model.
            string modelPath = GetModelPath();

            // Create three symbols for displaying a feature according to its distance from the camera.
            // First, a 3D model symbol (airplane) for when the camera is near the feature.
            ModelSceneSymbol plane3DSymbol = await ModelSceneSymbol.CreateAsync(new Uri(modelPath), 1.0);

            // 3D (blue cone) symbol for when the feature is at an intermediate range.
            SimpleMarkerSceneSymbol coneSym = new SimpleMarkerSceneSymbol(SimpleMarkerSceneSymbolStyle.Cone, Color.LightSkyBlue, 15, 6, 3, SceneSymbolAnchorPosition.Center)
            {
                // The cone will point in the same direction as the plane.
                Pitch = -90
            };

            // Simple marker symbol (circle) when the feature is far from the camera.
            SimpleMarkerSymbol markerSym = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.LightSkyBlue, 10.0);

            // Create three new ranges for displaying each symbol.
            DistanceSymbolRange closeRange = new DistanceSymbolRange(plane3DSymbol, 0, 100);
            DistanceSymbolRange midRange = new DistanceSymbolRange(coneSym, 100, 500);
            DistanceSymbolRange farRange = new DistanceSymbolRange(markerSym, 500, 0);

            // Create a new DistanceCompositeSceneSymbol and add the ranges.
            DistanceCompositeSceneSymbol compositeSymbol = new DistanceCompositeSceneSymbol();
            compositeSymbol.Ranges.Add(closeRange);
            compositeSymbol.Ranges.Add(midRange);
            compositeSymbol.Ranges.Add(farRange);

            // Return the new composite symbol.
            return compositeSymbol;
        }

        private static string GetModelPath()
        {
            return DataManager.GetDataFolder("681d6f7694644709a7c830ec57a2d72b", "Bristol.dae");
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.UseDistanceCompositeSym.UseDistanceCompositeSym"
             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"/>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
UseDistanceCompositeSymChange a graphic's symbol based on the camera's proximity to it.