3D Elevation Source

Download Samples Repository

Description

Demonstrates adding an ElevationSource to a Scene in XAML.

"Desktop" Available for Desktop

Sample Code

<UserControl 
	x:Class="ArcGISRuntime.Samples.Desktop.ElevationSourceSample3d"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
	xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
	mc:Ignorable="d" 
	d:DesignHeight="300" d:DesignWidth="300">
	<Grid>
		<esri:SceneView x:Name="MySceneView">
			<esri:Scene>
				<esri:Scene.Surface>
					<esri:ServiceElevationSource IsEnabled="True" 
						ServiceUri="http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"/>
				</esri:Scene.Surface>
				<esri:ArcGISTiledMapServiceLayer ID="Imagery"
					ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer" />
			</esri:Scene>
		</esri:SceneView>
	</Grid>
</UserControl>
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Geometry;
using System;
using System.Diagnostics;
using System.Windows;

namespace ArcGISRuntime.Samples.Desktop
{
	/// <summary>
	/// Demonstrates adding an ElevationSource to a Scene in XAML.
	/// </summary>
	/// <title>3D Elevation Source</title>
	/// <category>Scene</category>
	/// <subcategory>Elevation</subcategory>
	public partial class ElevationSourceSample3d
	{
		public ElevationSourceSample3d()
		{
			InitializeComponent();
			MySceneView.SpatialReferenceChanged += MySceneView_SpatialReferenceChanged;
		}

		private async void MySceneView_SpatialReferenceChanged(object sender, System.EventArgs e)
		{
			MySceneView.SpatialReferenceChanged -= MySceneView_SpatialReferenceChanged;

			try
			{
				// Set camera and navigate to it
				var viewpoint = new Camera(
					new MapPoint(
						-122.41213238640989, 
						37.78073901800655, 
						80.497554714791477),
						 53.719780233659428, 
						 73.16171159612496);
				await MySceneView.SetViewAsync(viewpoint, 1, true);
			}
			catch (Exception ex)
			{
				MessageBox.Show("Error occured while navigating to the target viewpoint",
					"An error occured");
				Debug.WriteLine(ex.ToString());
			}
		}
	}
}
Feedback on this topic?