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 Runtime API for Qt is installed.

Steps

Create a new ArcGIS Runtime Qt Creator Project

Use Qt Creator to create 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 Runtime 100.10 Qt Quick C++ 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 Runtime 100.10 Qt Quick C++ 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 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. On the Kit Selection dialog, check the kit(s) you previously set up when you installed the API. You should select a Desktop kit to run this tutorial. Click Next.

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

  8. Verify your selections and click Finish.

Get the 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 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
    Add line.
    40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 41 42 43 44 45 46 47 48 48 48 48 48
    //   Copyright 2020 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
    //
    //   https://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.
    
    #ifndef DISPLAY_A_SCENE_H
    #define DISPLAY_A_SCENE_H
    
    namespace Esri
    {
    namespace ArcGISRuntime
    {
    class Scene;
    class SceneQuickView;
    }
    }
    
    #include <QObject>
    
    class Display_a_scene : public QObject
    {
        Q_OBJECT
    
        Q_PROPERTY(Esri::ArcGISRuntime::SceneQuickView* sceneView READ sceneView WRITE setSceneView NOTIFY sceneViewChanged)
    
    public:
        explicit Display_a_scene(QObject* parent = nullptr);
        ~Display_a_scene() override;
    
    signals:
        void sceneViewChanged();
    
    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();
    
    };
    
    #endif // DISPLAY_A_SCENE_H
  3. In the Projects window, open the Sources folder. Open the Display_a_scene.cpp file.

  4. Delete the code from the body of the constructor.

    Display_a_scene.cpp
    Remove lineRemove lineRemove lineRemove lineRemove line
    25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 26 27 28 29 30 31 32 33 34 35 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
    //   Copyright 2020 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
    //
    //   https://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.
    //
    
    #include "Display_a_scene.h"
    
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
        QObject(parent), m_scene(new Scene(Basemap::imagery(this), 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);
    
    }
    
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
        return m_sceneView;
    }
    
    // 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();
    }
    
  5. Inside the constructor, set the API key. Replace the string YOUR_API_KEY with the key from your dashboard.

    Display_a_scene.cpp
    Add line.Add line.Add line.Add line.
    25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 26 27 28 29 30 31 32 33 33 32 31 31 31 31 31 31 31 31 31 31 31 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 12 12 12 11 10 9 6 3 0 -3 -6 -8 -10 -12 -13
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  6. Add this line to call to the new method you will create, setupScene.

    Display_a_scene.cpp
    Add line.
    25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 26 27 28 29 30 31 32 33 34 35 36 37 37 37 37 37 37 37 37 37 37 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 18 18 18 17 16 15 12 9 6 3 0 -2 -4 -6 -7
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  7. Create the new method named setupScene at the end of this file, after the close brace of setSceneView();

    Display_a_scene.cpp
    Add line.Add line.Add line.Add line.
    47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 48 49 50 51 52 53 54 55 56 57 57 57 57 57 57 57 57 57 57 58 59 60 61 62 63 62 61 60 59 58 58 58 58 59
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  8. Create an ElevationSource 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
    Add line.
    69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 50 50 50 51 52 53 54 54 52 50 48 47 46 45 45
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  9. Create a Surface and append the elevationSource to it.

    Display_a_scene.cpp
    Add line.Add line.
    72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 53 53 53 53 53 53 54 55 56 57 57 56 55 54 54
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  10. Set the ElevationExaggeration value (to improve elevation visibility), and then set the elevationSurface for m_scene.

    Display_a_scene.cpp
    Add line.Add line.
    74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 55 55 55 55 55 55 55 55 56 57 58 59 60 60 60
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  11. Inside of the setSceneView() method, create a Camera with the given parameters.

    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:

    • 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
    Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.
    47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65
    //   Copyright 2020 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
    //
    //   https://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.
    
    #include "Display_a_scene.h"
    
    #include "ArcGISRuntimeEnvironment.h"
    #include "ArcGISTiledElevationSource.h"
    #include "Basemap.h"
    #include "Scene.h"
    #include "SceneQuickView.h"
    
    #include <QUrl>
    
    using namespace Esri::ArcGISRuntime;
    
    Display_a_scene::Display_a_scene(QObject* parent /* = nullptr */):
      QObject(parent),
      m_scene(new Scene(Basemap::imagery(this), this))
    
    {
      // Note: It is not best practice to store API keys in source code. The API key is referenced here for the convenience of this tutorial.
      const QString api_key = QStringLiteral("YOUR_API_KEY");
      ArcGISRuntimeEnvironment::setApiKey(api_key);
    
      setupScene();
    
    }
    
    Display_a_scene::~Display_a_scene()
    {
    }
    
    SceneQuickView* Display_a_scene::sceneView() const
    {
      return m_sceneView;
    }
    
    // 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);
    
      emit sceneViewChanged();
    }
    
    void Display_a_scene::setupScene()
    {
    
      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);
    
      elevationSurface->setElevationExaggeration(2.5);
      m_scene->setBaseSurface(elevationSurface);
    
    }
    
  12. 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 platform services, and ArcGIS tools in these tutorials: