Identify features in a scene to select.
Use case
You can select features to visually distinguish them with a selection color or highlighting. This can be useful to demonstrate the physical extent or associated attributes of a feature, or to initiate another action such as centering that feature in the scene view.
How to use the sample
Tap on a building in the scene layer to select it. Deselect buildings by clicking away from the buildings.
How it works
- Create an
ArcGISSceneLayer
passing in the URL to a scene layer service. - Wait for the user to tap with the
sceneView.GeoViewTapped
event and get the tapped screen point. - Call
sceneView.IdentifyLayersAsync(sceneLayer, screenPoint, tolerance, false, 1)
to identify features in the scene. - From the resulting
IdentifyLayerResult
, get the list of identifiedGeoElements
withresult.GeoElements
. - 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 Brest, France Scene hosted on ArcGIS Online.
Tags
3D, Brest, buildings, identify, model, query, search, select
Sample Code
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.SceneLayerSelection.SceneLayerSelection"
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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.Row="0"
HorizontalTextAlignment="Center"
Text="Tap to select buildings." />
<esriUI:SceneView x:Name="MySceneView"
Grid.Row="1"
GeoViewTapped="SceneViewTapped" />
</Grid>
</ContentPage>