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

Before starting this tutorial:

  1. You need an ArcGIS Location Platform or ArcGIS Online account.

  2. Your system meets the system requirements.

  3. The ArcGIS Maps SDK for Qt, version 200.6.0 or later is installed.

  4. The Qt 6.5.6 software development framework is installed.

Create a new ArcGIS Maps Qt Creator Project

  1. Start Qt Creator.

  2. In the top menu bar, click File > New Project.

  3. In the New Project dialog, in the left frame, under Projects, select ArcGIS. Then select the ArcGIS Maps 200.6.0 Qt Quick C++ app project template (or a later version) and click Choose. This will launch the template wizard.

  4. In the Project Location template, name your project Display_a_scene. You can specify your own "create in" location for where the project will be created or leave the default. Click Next.

  5. In the Define Build System template, select qmake for your build system. Click Next.

  6. In the Define Project Details template, give this app a description or leave as is. Check ON the 3D project check box. At the ArcGIS Online Basemap dropdown menu, select Imagery. Accept the default value for the ArcGIS Online Elevation (WorldElevation3D) dropdown. There is no need to supply an API Key (also called an access token) at this time, you can leave it blank. We will discuss this more in the next section. Click Next.

  7. In the Kit Selection template, check on the kit you previously set up when you installed Qt (Desktop Qt 6.5.6 MSVC2019 64bit or higher required). Click Next.

  8. In the Project Management template, the option to Add as a subproject to root project is only available if you have already created a root project. If you have a version control system set up, you can select it in the dropdown but it is not needed to complete this tutorial. Click Finish to complete the template wizard.

Get an access token

You need an access token to use the location services used in this tutorial.

  1. Go to the Create an API key tutorial to obtain an access token using your ArcGIS Location Platform or ArcGIS Online account.

  2. Ensure that the following privilege is enabled: Location services > Basemaps > Basemap styles service.

  3. Copy the access token as it will be used in the next step.

To learn more about other ways to get an access token, go to Types of authentication.

Set your API key

In the Projects window, open the Sources folder. Open the main.cpp file. Paste the access token between the double quotes on the line indicated. Save and close the file.

main.cpp
Expand
Use dark colors for code blocks
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
    // 2. API key authentication: Get a long-lived access token that gives your application access to
    // ArcGIS location services. Go to the tutorial at https://links.esri.com/create-an-api-key.
    // Copy the API Key access token.

    const QString accessToken = QString("");
Expand

Display a scene

  1. In the Projects window, open the Headers folder. Double-click the file Display_a_scene.h to open it.

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

    Display_a_scene.h
    Expand
    Use dark colors for code blocks
    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
  3. 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
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
    #include "Display_a_scene.h"
    
    
    #include "ArcGISTiledElevationSource.h"
    
    #include "Camera.h"
    
  4. Add this line to call to the new method, setupScene, that you will create.

    Display_a_scene.cpp
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
    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();
    
    }
    
  5. Create the new method named setupScene at the end of this file, after the closing brace of setSceneView().

    Display_a_scene.cpp
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
    // 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()
    {
    
    }
  6. Create an ElevationSource 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
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
    void Display_a_scene::setupScene()
    {
    
      ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);
    
  7. Create a Surface instance and append the elevationSource to it.

    Display_a_scene.cpp
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
      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);
    
  8. Set the ElevationExaggeration value (to improve elevation visibility), and then set the elevationSurface for m_scene.

    Display_a_scene.cpp
    Use dark colors for code blocks
    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
    93
    94
    95
    96
    97
    98
      Surface* elevationSurface = new Surface(this);
      elevationSurface->elevationSources()->append(elevationSource);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
  9. 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
    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
    93
    94
    95
    96
    97
    98
    // 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
  10. 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.

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.