Display a scene

Learn how to create and display a scene with a basemap layer and an elevation layer. Set properties of the scene's camera to control the 3D perspective.

display a scene

Like a map, a scene contains layers of geographic data. It contains a basemap layer and, optionally, one or more data layers. To provide a realistic view of the terrain, you can also add elevation layers to define the height of the surface across the scene. The 3D perspective of the scene is controlled by the scene's camera, which defines the position of the scene observer in 3D space.

In this tutorial, you create and display a scene using the imagery basemap layer. The surface of the scene is defined with an elevation layer and the camera is positioned to display an area of the Santa Monica Mountains in the scene view.

The scene and code will be used as the starting point for other 3D tutorials.

Prerequisites

The following are required for this tutorial:

  1. An ArcGIS account to access API keys. If you don't have an account, sign up for free.
  2. Your system meets the system requirements.
  3. The ArcGIS Maps SDK for Qt, version 200.0.0 or later is installed. ArcGIS Maps SDK for Qt version 200.0.0 and later requires Qt 6.
  4. The Qt 6 software development framework is installed.

Choose your API

You can do this tutorial in C++ or QML:

Steps for C++

Create a new ArcGIS Maps Qt Creator Project

Use Qt Creator to create an app that displays a Scene centered on the Santa Monica Mountains in Southern California.

  1. Start Qt Creator.

  2. Click File > New File or Project. In the left frame, under Projects, select ArcGIS.

  3. Select the ArcGIS Maps 200.0.0 Qt Quick C++ app project template, or a later version, and click Choose.

    You may see several selections for the ArcGIS project type. Be sure to select ArcGIS Maps 200.0.0 Qt Quick C++ app (or a later version).

  4. At the Project Location dialog, name your project Display_a_scene. Click Next.

  5. At the Define Build System dialog, select qmake for your build system. Click Next.

  6. At the Define Project Details dialog, enter a description for this app (or leave it as is). Click 3D project. At the ArcGIS Online Basemap dropdown menu, select Imagery. Leave the rest of this dialog unchanged and click Next.

  7. At the Kit Selection dialog, check the kit(s) you previously set up when you installed Qt. You should select a Desktop kit to perform all steps in this tutorial. Click Next.

    The Add as a subproject to root project option is only available if you have already created a root project. Ignore this option for this tutorial.

  8. Verify your selections and click Finish.

Get an API key

An API key is required to enable access to services, web maps, and web scenes hosted in ArcGIS Online.

If you haven't already, go to your developer dashboard to get your API key. For these tutorials, use your default API key. It is scoped to include all of the services demonstrated in the tutorials.

Display a scene

  1. In the Projects window, open the Sources folder. Open the main.cpp file. Paste the API key (that you retrieved from your dashboard) between the quotes on the line indicated. Then save and close the file.

    main.cpp
    Expand
    Use dark colors for code blocks
    45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 46 47 48 49 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
        // 2. API key: A permanent key that gives your application access to Esri
        // location services. Create a new API key or access existing API keys from
        // your ArcGIS for Developers dashboard (https://links.esri.com/arcgis-api-keys).
    
        const QString apiKey = QString("");
    
    Expand
  2. In the Projects window, open the Headers folder. Double-click the file Display_a_scene.h to open it.

  3. Add the declaration void setupScene(); under private:. Then save and close the file.

    Display_a_scene.h
    Expand
    Use dark colors for code blocks
    37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 38 39 40 41 42 43 44 45 45 45 45 45
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    private:
        Esri::ArcGISRuntime::SceneQuickView* sceneView() const;
        void setSceneView(Esri::ArcGISRuntime::SceneQuickView* sceneView);
    
        Esri::ArcGISRuntime::Scene* m_scene = nullptr;
        Esri::ArcGISRuntime::SceneQuickView* m_sceneView = nullptr;
    
        void setupScene();
    
    Expand
  4. In the Projects window, open the Sources folder. Open the Display_a_scene.cpp file. This app will use a Camera object to display the scene. Add the following include statement.

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    12 12 12 12 12 12 12 12 12 12 12 12 13 14 15 16 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    #include "Display_a_scene.h"
    
    #include "ArcGISTiledElevationSource.h"
    
    #include "Camera.h"
    
    Expand
  5. Add this line to call to the new method, setupScene, that you will create.

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 46 46 46 46 46 46 46 46 46 46 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 26 26 26 25 24 23 20 17 14 11 8 6 4 2 1
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
    
        QObject(parent),
    
        m_scene(new Scene(BasemapStyle::ArcGISImagery, this))
    
    {
        // create a new elevation source from Terrain3D rest service
        ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(
                    QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);
    
        // add the elevation source to the scene to display elevation
        m_scene->baseSurface()->elevationSources()->append(elevationSource);
    
    
        setupScene();
    
    }
    
    Expand
  6. Create the new method named setupScene at the end of this file, after the closing brace of setSceneView().

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 58 59 60 61 62 63 64 65 66 67 68 68 68 68 68 68 68 68 68 68 69 70 71 72 73 74 73 72 71 70 69 69 69 69 70
    Add line.Add line.Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    // Set the view (created in QML)
    void Display_a_scene::setSceneView(SceneQuickView* sceneView)
    {
        if (!sceneView || sceneView == m_sceneView)
        {
            return;
        }
    
        m_sceneView = sceneView;
        m_sceneView->setArcGISScene(m_scene);
    
        emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
    }
  7. Create an instance to define the base surface for the scene.

    An elevation source can define a surface with 3D terrain in a scene. Without an elevation source, the default globe surface is used to display the scene.

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 60 60 60 61 62 63 64 64 62 60 58 57 56 55 55
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    void Display_a_scene::setupScene()
    {
    
      ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);
    
    Expand
  8. Create a Surface instance and append the elevationSource to it.

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 63 63 63 63 63 63 64 65 66 67 67 66 65 64 64
    Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
      ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);
    
      Surface* elevationSurface = new Surface(this);
      elevationSurface->elevationSources()->append(elevationSource);
    
    Expand
  9. Set the ElevationExaggeration value (to improve elevation visibility), and then set the elevationSurface for m_scene.

    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 65 65 65 65 65 65 65 65 66 67 68 69 70 70 70
    Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
      Surface* elevationSurface = new Surface(this);
      elevationSurface->elevationSources()->append(elevationSource);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    Expand
  10. Inside of the setSceneView() method, create a Camera with the given parameters.

    The position from which you view the scene from is defined by a Camera. The following properties of the camera are used to define an observation point in the scene:

    • latitude: The measurement of distance north or south of the Equator
    • longitude: The measurement east or west of the prime meridian
    • altitude: The distance above sea level
    • heading: Azimuth of the camera's direction
    • pitch: Up and down angle
    • roll: Side-to-side angle
    Display_a_scene.cpp
    Expand
    Use dark colors for code blocks
    57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76 76
    Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    // Set the view (created in QML)
    void Display_a_scene::setSceneView(SceneQuickView* sceneView)
    {
        if (!sceneView || sceneView == m_sceneView)
        {
            return;
        }
    
        m_sceneView = sceneView;
        m_sceneView->setArcGISScene(m_scene);
    
        constexpr double latitude = 33.909;
        constexpr double longitude = -118.805;
        constexpr double altitude = 5330.0;
        constexpr double heading = 355.0;
        constexpr double pitch = 72.0;
        constexpr double roll = 0.0;
        const Camera sceneCamera(latitude, longitude, altitude, heading, pitch, roll);
        m_sceneView->setViewpointCameraAndWait(sceneCamera);
    
    Expand
  11. Press <Ctrl+R> to run the app.

You should see a scene with the topographic basemap layer centered on the Santa Monica Mountains in California. Double-click, drag, and scroll the mouse wheel over the scene view to explore the scene.

Steps for QML

Create a new ArcGIS Maps Qt Creator Project

Use Qt Creator to create an app that displays a Scene centered on the Santa Monica Mountains.

  1. Start Qt Creator.

  2. Click File > New File or Project. In the left frame, under Projects, select ArcGIS.

  3. Select the ArcGIS Maps 200.0.0 Qt Quick QML app project template, or a later version, and click Choose.

    You may have several selections for the ArcGIS project type. Be sure to select ArcGIS Maps 200.0.0 Qt Quick QML app (or a later version).

  4. On the Project Location dialog, name your project Display_a_scene. Click Next.

  5. On the Define Build System dialog, select qmake for your build system. Click Next.

  6. On the Define Project Details dialog, give this app a description or leave it as is. Click 3D project. At the ArcGIS Online Basemap dropdown menu, select Imagery. For your application, this selection will create a Surface using an ArcGISTiledElevationSource from an ArcGIS image server. Leave the rest of this dialog unchanged and click Next.

  7. On the Kit Selection dialog, check the kit(s) you previously set up when you installed Qt. You should select a Desktop kit to run this tutorial. Click Next.

    The Add as a subproject to root project option is only available if you have already created a root project. Ignore this option for this tutorial.

  8. Verify your selections and click Finish.

Get an API key

An API key is required to enable access to services, web maps, and web scenes hosted in ArcGIS Online.

If you haven't already, go to your developer dashboard to get your API key. For these tutorials, use your default API key. It is scoped to include all of the services demonstrated in the tutorials.

  1. In the Projects window, open the Sources folder and open the main.cpp file.

  2. Paste the API key (you retrieved from your dashboard) between the quotes on the line indicated. Then save and close the file.

    main.cpp
    Expand
    Use dark colors for code blocks
    41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 42 43 44 45 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46
    Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
        // 2. API key: A permanent key that gives your application access to Esri
        // location services. Create a new API key or access existing API keys from
        // your ArcGIS for Developers dashboard (https://links.esri.com/arcgis-api-keys).
    
        const QString apiKey = QString("");
    
    Expand

Use an image server and camera to display a scene

  1. If the main.qml file is not already open, in the Projects window, navigate to Resources > qml\qml.qrc > /qml and open the main.qml file.

  2. Within the SceneView, add code to set a 3D Viewpoint on a Camera, which you will add in the next step.

    main.qml
    Expand
    Use dark colors for code blocks
    32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 47 47 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 33
    Add line.Add line.Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    
                // add a surface, surface is a default property of scene
                Surface {
                    // add an arcgis tiled elevation source...elevation source is a default property of surface
                    ArcGISTiledElevationSource {
                        url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
                    }
                }
    
            }
    
            Component.onCompleted: {
                // set viewpoint to the specified camera
                setViewpointCameraAndWait(camera);
            }
    
    Expand
  3. Add the following code to create a Camera. Provide a Point for the camera location and provide camera properties.

    The position you view the scene from is defined by a Camera. The following properties of the camera are used to define an observation point in the scene:

    • 3D location: Longitude (x), latitude (y), and altitude (z)
    • heading: Azimuth of the camera's direction
    • pitch: Up and down angle
    • roll: Side-to-side angle
    main.qml
    Expand
    Use dark colors for code blocks
    43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 63 63
    Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
            Component.onCompleted: {
                // set viewpoint to the specified camera
                setViewpointCameraAndWait(camera);
            }
    
        }
    
        Camera {
            id: camera
            heading: 355.0
            pitch: 72.0
            roll: 0.0
    
            Point {
                x: -118.794
                y: 33.909
                z: 5330.0
                spatialReference: SpatialReference { wkid: 4326 }
            }
        }
    
    Expand
  4. Press <Ctrl+R> to run the app.

You will see a scene with the topographic basemap layer centered on the Santa Monica Mountains in California. Double-click, drag, and scroll the mouse wheel over the scene view to explore the scene.

What's next?

Learn how to use additional API features, ArcGIS location services, and ArcGIS tools in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.