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.
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:
An ArcGIS account to access API keys. If you don't have an account, sign up for free.
Use Qt Creator to create an app that displays a Scene centered on the Santa Monica Mountains in Southern California.
Start Qt Creator.
Click File > New File or Project. In the left frame, under Projects, select ArcGIS.
Select the ArcGIS Maps 200.2.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.2.0 Qt Quick C++ app (or a later version).
At the Project Location dialog, name your project Display_a_scene. Click Next.
At the Define Build System dialog, select qmake for your build system. Click Next.
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.
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.
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
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.
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.
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.
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
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.
Start Qt Creator.
Click File > New File or Project. In the left frame, under Projects, select ArcGIS.
Select the ArcGIS Maps 200.2.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.2.0 Qt Quick QML app (or a later version).
On the Project Location dialog, name your project Display_a_scene. Click Next.
On the Define Build System dialog, select qmake for your build system. Click Next.
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.
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.
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.
In the Projects window, open the Sources folder and open the main.cpp file.
Paste the API key (you retrieved from your dashboard) between the quotes on the line indicated. Then save and close the file.
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 sceneSurface {
// add an arcgis tiled elevation source...elevation source is a default property of surfaceArcGISTiledElevationSource {
url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer" }
}
}
Component.onCompleted: {
// set viewpoint to the specified camera setViewpointCameraAndWait(camera);
}
Expand
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)
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.