Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for .NET

Scene layer selection

This code sample is available for these platforms:
View Sample on GitHub

Identify GeoElements in a scene layer.


How to use the sample

Click on a building in the scene layer to select it. Deselect buildings by clicking away from the buildings.

How it works

  1. Create an ArcGISSceneLayer passing in the URL to a scene layer service.
  2. Wait for the user to tap with the sceneView.GeoViewTapped event and get the tapped screen point.
  3. Call sceneView.IdentifyLayersAsync(sceneLayer, screenPoint, tolerance, false, 1) to identify features in the scene.
  4. From the resulting IdentifyLayerResult, get the list of identified GeoElements with result.GeoElements.
  5. Get the first element in the list, checking that it is a feature, and call sceneLayer.SelectFeature(feature) to select it.

Relevant API

  • ArcGISSceneLayer
  • Scene
  • SceneView

About the data

This sample shows a Berlin building layer from ArcGIS Online.


3D, Buildings, Search and Query, model, scene

Sample Code

        <esriUI:SceneView x:Name="MySceneView"
                          GeoViewTapped="SceneViewTapped" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock Text="Tap to select buildings."
                       TextAlignment="Center" FontWeight="SemiBold" />
// Copyright 2018 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:
// 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 Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Popups;
using Esri.ArcGISRuntime.Geometry;

namespace ArcGISRuntime.UWP.Samples.SceneLayerSelection
        "Scene layer selection",
        "Identify GeoElements in a scene layer.",
        "Tap/Click on a building in the scene layer to identify it.",
    public partial class SceneLayerSelection
        public SceneLayerSelection()

        private async void Initialize()
            // Create a new Scene with an imagery basemap.
            Scene scene = new Scene(Basemap.CreateImagery());

            // Add a base surface with elevation data.
            Surface elevationSurface = new Surface();
            Uri elevationService = new Uri("");
            elevationSurface.ElevationSources.Add(new ArcGISTiledElevationSource(elevationService));
            scene.BaseSurface = elevationSurface;

            // Add a scene layer.
            Uri buildingsService = new Uri("");
            ArcGISSceneLayer buildingsLayer = new ArcGISSceneLayer(buildingsService);

                // Assign the Scene to the SceneView.
                MySceneView.Scene = scene;

                // Create a camera with an interesting view.
                await buildingsLayer.LoadAsync();
                MapPoint center = (MapPoint)GeometryEngine.Project(buildingsLayer.FullExtent.GetCenter(), SpatialReferences.Wgs84);
                Camera viewCamera = new Camera(center.Y, center.X, 600, 120, 60, 0);

                // Set the viewpoint with the camera.
            catch (Exception e)
                await new MessageDialog(e.ToString(), "Error").ShowAsync();

        private async void SceneViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
            // Get the scene layer from the scene (first and only operational layer).
            ArcGISSceneLayer sceneLayer = (ArcGISSceneLayer)MySceneView.Scene.OperationalLayers.First();

            // Clear any existing selection.

                // Identify the layer at the tap point.
                // Use a 10-pixel tolerance around the point and return a maximum of one feature.
                IdentifyLayerResult result = await MySceneView.IdentifyLayerAsync(sceneLayer, e.Position, 10, false, 1);

                // Get the GeoElements that were identified (will be 0 or 1 element).
                IReadOnlyList<GeoElement> geoElements = result.GeoElements;

                // If a GeoElement was identified, select it in the scene.
                if (geoElements.Any())
                    GeoElement geoElement = geoElements.FirstOrDefault();
                    if (geoElement != null)
                        // Select the feature to highlight it in the scene view.
            catch (Exception ex)
                await new MessageDialog(ex.ToString(), "Error").ShowAsync();