Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app that displays feature layers in a 3D scene.

Applications can access and display feature layers that are hosted on ArcGIS Online or ArcGIS Enterprise and draw them on a 3D scene. A hosted feature layer contains features (records) with a geometry and a set of attributes. Each hosted feature layer has a REST endpoint with a unique URL. A FeatureLayer class can use this URL to access the layer's point, line, or polygon features. These features may be drawn on the scene with the SceneQuickView class. If properties such as the renderer or pop-up have not been pre-defined for the hosted feature layer, the map will use default symbols and pop-ups will not be enabled.

In this tutorial, you will add the Trailheads, Trails, and Parks and open spaces hosted feature layers to the map.

Before you begin

You must have previously installed the ArcGIS Runtime SDK for Qt and set up the development environment for your operating system.


Create a new (3D) ArcGIS Runtime App Qt Creator Project

  1. Start Qt Creator.

  2. Choose the ArcGIS Runtime Qt Quick C++ project template.

  3. Give your app a name. For this tutorial we chose add_layers_to_a_3d_scene, but you can choose any name that suits you. Click Next.

  4. On the Define Project Details dialog, click the checkbox 3D project. Leave all the other settings as they are and click Continue.

  5. On the Kit Selection dialog, choose one of the kits you previously setup when you installed the Qt Framework. Click Next.

  6. Verify your selections and click Done.

Import header statements

  1. In Projects, double click on Sources > Add_layers_to_a_3d_scene.cpp and add the following include statements.

    #include "SceneQuickView.h"
    // *** ADD ***
    #include "FeatureLayer.h"
    #include "ServiceFeatureTable.h"

Add a feature layer

  1. Add the following code to the body of the constructor to load a feature layer.

    Add_layers_to_a_3d_scene::Add_layers_to_a_3d_scene(QObject* parent /* = nullptr */):
      m_scene(new Scene(Basemap::topographic(this), this))
      // create a new elevation source from Terrain3D rest service
      ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(
         QUrl(""), this);
      // add the elevation source to the scene to display elevation
      // *** ADD ***
      QUrl serviceURL("");
      ServiceFeatureTable* f_table = new ServiceFeatureTable(serviceURL, this);
      FeatureLayer* f_layer = new FeatureLayer(f_table, this);
  2. At the end of the body of the constructor, append the feature layer to the operational layers of the scene.

      FeatureLayer* f_layer = new FeatureLayer(f_table, this);
      // *** ADD ***

Create and position the scene

  1. Add the setSceneView member function to set the initial position of the Camera of the scene view.

    void Add_layers_to_a_3d_scene::setSceneView(SceneQuickView* sceneView)
      if (!sceneView || sceneView == m_sceneView)
      m_sceneView = sceneView;
      // *** ADD ***
      constexpr double latitude = 33.855;
      constexpr double longitude = -118.85;
      constexpr double altitude = 10010.0;
      constexpr double heading = 40.0;
      constexpr double pitch = 80.0;
      constexpr double roll = 0.0;
      Camera camera(latitude, longitude, altitude, heading, pitch, roll);
  2. Run your app to test your code. You should see a 3D perspective of the scene with the trails drawn on the map.

Congratulations, you're done!

Compare your project with our completed solution project.


Explore basemaps

Look at the available basemaps at the Basemap class in the API reference documentation. Modify your code to display a different basemap.

To learn more, check out the working with scenes guide topic.

Add additional feature layers

Visit ArcGIS Online and find additional interesting park datasets to load into the app. Here are a few suggestions:

  • Trailheads (points):
  • Parks (polygons):

Filter features in the trailheads layer

Sometimes you want your layer to show a subset of the data from a service. A definition expression lets you define attribute criteria that restrict the features for a layer. Consult the service info for the Trailheads data source and construct an expression for the layer's definitionExpression property that will show only those trailheads that do not have parking.