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 tapping away from the buildings.
How it works
- Create an instance of
ArcGISSceneLayer, passing in the URL to a scene layer service. - Use the
onSingleTapConfirmedon theSceneViewto get the screen tapped location. - Use
SceneViewProxy.identify(layer, screenCoordinate, tolerance)to identify features in the scene. - From the resulting
IdentifyLayerResult, get the list of identifiedGeoElements. - Get the first
ArcGISFeaturein the list and useArcGISSceneLayer.selectFeature(features).
Relevant API
- ArcGISSceneLayer
- Scene
- SceneView
- SceneViewProxy
- SceneViewReader
About the data
This sample shows a Brest France Buildings Scene hosted on ArcGIS Online.
Tags
3D, buildings, identify, model, query, search, select
Sample code
/* Copyright 2026 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. * */
package com.esri.arcgismaps.sample.selectfeaturesinscenelayer.components
import android.app.Applicationimport androidx.compose.ui.unit.dpimport androidx.lifecycle.AndroidViewModelimport androidx.lifecycle.viewModelScopeimport com.arcgismaps.data.ArcGISFeatureimport com.arcgismaps.mapping.ArcGISSceneimport com.arcgismaps.mapping.ArcGISTiledElevationSourceimport com.arcgismaps.mapping.BasemapStyleimport com.arcgismaps.mapping.Surfaceimport com.arcgismaps.mapping.Viewpointimport com.arcgismaps.mapping.layers.ArcGISSceneLayerimport com.arcgismaps.mapping.view.Cameraimport com.arcgismaps.mapping.view.SingleTapConfirmedEventimport com.arcgismaps.toolkit.geoviewcompose.SceneViewProxyimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogViewModelimport kotlinx.coroutines.launch
class SelectFeaturesInSceneLayerViewModel(app: Application) : AndroidViewModel(app) {
// Create a SceneViewProxy which is passed to the composable SceneView val sceneViewProxy = SceneViewProxy()
// The layer added to the scene's operational layers. private val sceneLayer = ArcGISSceneLayer(BREST_BUILDING_SERVICE)
// Initial Camera object val camera = Camera( latitude = 48.38282, longitude = -4.49779, altitude = 40.0, heading = 41.65, pitch = 71.2, roll = 0.0 ) // Create a scene to be present on scene view val scene = ArcGISScene(BasemapStyle.ArcGISImagery).apply { // Add base surface for elevation data baseSurface = Surface().apply { elevationSources.add(ArcGISTiledElevationSource(uri = WORLD_ELEVATION_SERVICE_URL)) }
// Add the scene layer with features to select operationalLayers.add(sceneLayer)
// Set the initial viewpoint of the scene initialViewpoint = Viewpoint(boundingGeometry = camera.location, camera = camera) }
// Create a message dialog view model for handling error messages val messageDialogVM = MessageDialogViewModel()
init { // Load the map and handle any errors by showing a message dialog viewModelScope.launch { scene.load().onFailure { messageDialogVM.showMessageDialog(it) } } }
/** * Identifies the tapped screen coordinate in the provided [tapEvent] * and selects the first identified [ArcGISFeature] */ fun identify(tapEvent: SingleTapConfirmedEvent) {
// Clear any previous selection sceneLayer.clearSelection()
viewModelScope.launch { sceneViewProxy.identify( layer = sceneLayer, screenCoordinate = tapEvent.screenCoordinate, tolerance = 12.dp, ).onSuccess { identifyResult -> identifyResult .geoElements .filterIsInstance<ArcGISFeature>() .firstOrNull() ?.let { arcGISFeature -> // Select the feature on the scene layer sceneLayer.selectFeature(arcGISFeature) } }.onFailure { messageDialogVM.showMessageDialog(it) } } }
companion object { // The URL of a Brest, France buildings scene service. private const val BREST_BUILDING_SERVICE = "https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0"
// World elevation service used to provide base surface elevation. private const val WORLD_ELEVATION_SERVICE_URL = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" }
}/* Copyright 2026 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. * */
package com.esri.arcgismaps.sample.selectfeaturesinscenelayer.screens
import androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.paddingimport androidx.compose.material3.Scaffoldimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.lifecycle.viewmodel.compose.viewModelimport com.arcgismaps.toolkit.geoviewcompose.SceneViewimport com.esri.arcgismaps.sample.sampleslib.components.MessageDialogimport com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBarimport com.esri.arcgismaps.sample.selectfeaturesinscenelayer.components.SelectFeaturesInSceneLayerViewModel
/** * Main screen layout for the sample app */@Composablefun SelectFeaturesInSceneLayerScreen( sampleName: String, viewModel: SelectFeaturesInSceneLayerViewModel = viewModel()) {
Scaffold( topBar = { SampleTopAppBar(title = sampleName) }, content = { SceneView( modifier = Modifier .fillMaxSize() .padding(it), // Pass the scene to the SceneView arcGISScene = viewModel.scene, sceneViewProxy = viewModel.sceneViewProxy, // Pass the tap event to identify a feature onSingleTapConfirmed = viewModel::identify ) } )
viewModel.messageDialogVM.apply { if (dialogStatus) { MessageDialog( title = messageTitle, description = messageDescription, onDismissRequest = ::dismissDialog ) } }}/* Copyright 2026 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. * */
package com.esri.arcgismaps.sample.selectfeaturesinscenelayer
import android.os.Bundleimport androidx.activity.ComponentActivityimport androidx.activity.compose.setContentimport androidx.activity.enableEdgeToEdgeimport androidx.compose.material3.MaterialThemeimport androidx.compose.material3.Surfaceimport com.esri.arcgismaps.sample.sampleslib.theme.SampleAppThemeimport com.esri.arcgismaps.sample.selectfeaturesinscenelayer.screens.SelectFeaturesInSceneLayerScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { SampleAppTheme { Surface(color = MaterialTheme.colorScheme.background) { SelectFeaturesInSceneLayerScreen(sampleName = getString(R.string.select_features_in_scene_layer_sample_name)) } } } }}