Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Scene layer selection

Sample Viewer View Sample on GitHub

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

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 by passing in the URL to a scene layer service.
  2. Use SceneView.mouseClicked signal to get the screen tap location screen point.
  3. Call SceneView.identifyLayer to identify features in the scene that intersect the tapped screen point.
  4. From the resulting IdentifyLayerResult, a list of identified GeoElements are obtained.
  5. Get the first element in the list is obtained and ArcGISSceneLayer.selectFeature(feature) is used to select it.

About the data

This sample shows a Berlin, Germany Scene hosted on ArcGIS Online.

Relevant API

  • ArcGISSceneLayer
  • Scene
  • SceneView

Tags

3D, Berlin, buildings, identify, model, query, search, select

Sample Code

import QtQuick 2.6
import Esri.ArcGISRuntime 100.9

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    SceneView {
        id: sceneView
        anchors.fill: parent

        Scene {
            id: scene
            BasemapImagery {}

            // add a scene layer
            ArcGISSceneLayer {
                id: sceneLayer
                url: "https://tiles.arcgis.com/tiles/P3ePLMYs2RVChkJx/arcgis/rest/services/Buildings_Brest/SceneServer/layers/0"
            }

            // set an initial viewpoint
            ViewpointCenter {
                Point {
                    id: initialPoint
                    x: -4.49779155626782
                    y: 48.38282454039932
                    z: 62.013264927081764
                    spatialReference: SpatialReference { wkid: 4326 }
                }
                targetScale: 62.013264927081764

                Camera {
                    id: camera
                    location: initialPoint
                    heading: 41.64729875588979
                    pitch: 71.2017391571523
                    roll: 2.194677223e-314
                }
            }

            // add an elevation surface
            Surface {
                ArcGISTiledElevationSource {
                    url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
                }
            }
        }

        // handle the identifyLayerStatusChanged signal
        onIdentifyLayerStatusChanged: {
            if (identifyLayerStatus !== Enums.TaskStatusCompleted)
                return;

            // get the results
            const result = sceneView.identifyLayerResult;
            const geoElements = result.geoElements;

            // get the first GeoElement
            if (geoElements.length > 0) {
                // select the feature
                sceneLayer.selectFeature(geoElements[0]);
            }
        }

        // when the scene is clicked, identify the clicked feature and select it
        onMouseClicked: {
            // clear any previous selection
            sceneLayer.clearSelection();

            // identify from the click
            sceneView.identifyLayer(sceneLayer, mouse.x, mouse.y, 10, false);
        }
    }
}