3D Feature Layer from Local Geodatabase
Download Samples RepositoryDescription
This sample shows how to add a FeatureLayer from a local .geodatabase file to the scene.
Available for Desktop
Sample Code
<UserControl x:Class="ArcGISRuntime.Samples.Desktop.FeatureLayerFromLocalGeodatabase3d"
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" >
<Grid>
<esri:SceneView x:Name="MySceneView">
<esri:Scene>
<esri:ArcGISTiledMapServiceLayer DisplayName="Basemap"
ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
</esri:Scene>
</esri:SceneView>
<Border Background="White" BorderBrush="Black" BorderThickness="1"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="30" Padding="20">
<StackPanel>
<TextBlock Text="Layers" FontWeight="Bold" FontSize="16" Margin="0,0,0,8"/>
<ListView ItemsSource="{Binding ElementName=MySceneView, Path=Scene.Layers}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayName}" FontSize="14" Margin="4" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Border>
</Grid>
</UserControl>
using Esri.ArcGISRuntime.Controls;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Layers;
using System;
using System.Windows;
using System.Windows.Controls;
namespace ArcGISRuntime.Samples.Desktop
{
/// <summary>
/// This sample shows how to add a FeatureLayer from a local .geodatabase file to the scene.
/// </summary>
/// <title>3D Feature Layer from Local Geodatabase</title>
/// <category>Scene</category>
/// <subcategory>Feature Layers</subcategory>
public partial class FeatureLayerFromLocalGeodatabase3d : UserControl
{
private const string GeodatabasePath = @"..\..\..\samples-data\maps\usa.geodatabase";
public FeatureLayerFromLocalGeodatabase3d()
{
InitializeComponent();
CreateFeatureLayers();
}
private async void CreateFeatureLayers()
{
try
{
var geodatabase = await Geodatabase.OpenAsync(GeodatabasePath);
Envelope extent = null;
foreach (var table in geodatabase.FeatureTables)
{
var featureLayer = new FeatureLayer()
{
ID = table.Name,
DisplayName = table.Name,
FeatureTable = table
};
if (!Geometry.IsNullOrEmpty(table.ServiceInfo.Extent))
{
if (Geometry.IsNullOrEmpty(extent))
extent = table.ServiceInfo.Extent;
else
extent = extent.Union(table.ServiceInfo.Extent);
}
MySceneView.Scene.Layers.Add(featureLayer);
}
await MySceneView.SetViewAsync(new Camera(new MapPoint(-99.343, 26.143, 5881928.401), 2.377, 10.982));
}
catch (Exception ex)
{
MessageBox.Show("Error creating feature layer: " + ex.Message, "Samples");
}
}
}
}