A global scene
You can use a global sceneSceneView to:
- Display a basemap layer
A basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. such as streets or satellite imagery. - Access and display data layers
A data layer is a layer that references geographic data from a file or a service and is used to visualize the data in a map or scene. based on files or services, including data you have authored. - Display terrain with an elevation layer
An elevation layer is a layer that defines the ground height or the surface for a scene. . - Display real-world objects such as buildings, cars, and trees.
- Display 3D visualizations of 2D objects.
- Perform 3D analysis, such as line-of-sight, visibility, and 3D measurements.
- Provide context for temporary points, lines, polygons, or text displayed as graphics
A graphic is a visual element composed of a geometry, symbol, and attributes that is displayed on a map or scene. . - Measure distance and explore spatial relationships between geometries
A geometry is a geometric shape, such as a point, polyline, or polygon, that contains one or more coordinates and a spatial reference. . - Inspect data layers and display information from attributes
Attributes are fields and values for a single feature or non-spatial record. They are typically stored in a database or service such as a feature service. .
Scene
The introduction explained the concept of a sceneScene is your entry point into the API when working with three dimensional data. However, when working with global scenes you connect them with SceneView in order to display the data within an application. Remember that when you are working with global scenes, the SceneViewingMode is set to global. When creating a scene programmatically, the viewing mode needs to be set. If consuming a global web scene itemSceneViewingMode is set to local, consult the local scene overview topic for details as it is different from working with a global scene. Logically, when programmatically building a global scene, the next step is to add data layers
Layer
Each layer
Scenes can also contain scene layers
The Layer class is the base class for all types of layers used in ArcGIS Maps SDK for Qt. The type of layer you create depends on the type of data you want to display. For example, to display feature data you can create a FeatureLayer that references an online service (such as a feature serviceArcGISVectorTiledLayer and AnnotationLayer. Similarly, 3D layers cannot be displayed in Map, such as ArcGISSceneLayer.
void Layers::loadSceneLayers()
{
// Set the access token.
const QString accessToken = QStringLiteral("YOUR_ACCESS_TOKEN");
// Set the ArcGIS runtime environment Api Key with your access token.
ArcGISRuntimeEnvironment::setApiKey(accessToken);
// Create a new "trail heads" feature layer based on a service feature table (using the Url provided).
FeatureLayer* trailheadsLayer = new FeatureLayer(
new ServiceFeatureTable(QUrl("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_Styled/FeatureServer/0"), this),
this
);
// Create a new "trails" feature layer based on a service feature table (using the Url provided).
FeatureLayer* trailsLayer = new FeatureLayer(
new ServiceFeatureTable(QUrl("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0"), this),
this
);
// Create a new "open spaces" feature layer based on a service feature table (using the Url provided).
FeatureLayer* openSpacesLayer = new FeatureLayer(
new ServiceFeatureTable(QUrl("https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Parks_and_Open_Space_Styled/FeatureServer/0"), this),
this
);
// Add the three feature layers to the scene's operating layers list model collection.
m_scene->operationalLayers()->append(trailheadsLayer);
m_scene->operationalLayers()->append(trailsLayer);
m_scene->operationalLayers()->append(openSpacesLayer);
}
Camera
Global scenes and global scene views extend the concept of two dimensional viewpoints with a camera
The following properties define the camera position:
- Geographic location on the surface (longitude and latitude)
- Altitude (height, in meters, above sea level)
- Heading (angle about the z axis the camera is rotated, in degrees)
- Pitch (angle the camera is rotated up or down, in degrees)
- Roll (angle the camera is rotated side-to-side, in degrees)
// Create a camera
constexpr double latitude = 33.961;
constexpr double longitude = -118.808;
constexpr double altitude = 2000;
constexpr double heading = 0;
constexpr double pitch = 75;
constexpr double roll = 0;
const Camera camera(latitude, longitude, altitude, heading, pitch, roll);
SceneView has an associated controller that manages the camera
When a camera controller other than the default Globe is active, the scene view's viewpoint cannot be assigned. Attempts to do so do not raise an exception, but they are ignored.
The following camera controllers are provided:
GlobeCameraController(default) — Provides the default scene view camera behavior. Allows the user to freely move and focus the camera anywhere in the scene.OrbitGeoElementCameraController— Locks the scene view's camera to maintain focus relative to a (possibly moving) graphic. The camera can only move relative to the target graphic.OrbitLocationCameraController— Locks the scene view's camera to orbit a fixed location (map point). The camera can only move relative to the target map point.TransformationMatrixCameraController— Provides navigation by using aTransformationMatrixto control the camera's location and rotation. You need to pass this object to allTransformationfunctions.Matrix Camera Controller
// Create a camera controller to follow a geoelement in the scene view.
// Pass a geoelement (graphic) and a distance (meters).
OrbitGeoElementCameraController* orbitCam = new OrbitGeoElementCameraController(planeGraphic, 50, this);
orbitCam->setCameraPitchOffset(75);
// Apply our new orbiting camera to the scene view.
m_sceneView->setCameraController(orbitCam);
SceneView
A scene view
After creating a scene view, you typically set the scene
Add a Scene to a SceneView to display it. Changes you make to the scene, such as adding, removing, or reordering layers, will immediately be reflected in the display. The Scene::initialViewpoint() will determine the area shown when the scene loads.
// Create a scene view and set scene and viewpoint
SceneQuickView* sceneView = new SceneQuickView(scene);
sceneView->setArcGISScene(scene);
sceneView->setViewpointCameraAsync(camera);
A SceneView also allows you to:
- Adjust light, atmosphere, and space effects.
- Display image overlays on the scene surface.
- Lock the camera to a location or geoelement
A geoelement refers to any geographic element in a map or map view that can be identified by its location to return attribute information. . - Add analysis overlays to visualize analysis results.
- Identify and select features using a mouse or tap location.
- Export an image of the current display.
- Apply a time extent to filter the display of features.
View error
The SceneView supports an error that helps to capture different situations and provides useful messages to help troubleshoot related problems that may arise. Ultimately, you decide what you want to do with the error. For example, you may decide to enter the information into a log for further examination as users report problems with your application.
GeoModel error
When working with SceneView there are situations that arise when the view is in a usable state, but nothing is displayed because the GeoModel is not configured correctly.
Examples
Display a global scene with elevation
This example uses a Scene and SceneView to display the topographic basemap layerCamera is created to define the initial view of the scene.
Steps
- Create a
Sceneand add a basemap layerA basemap layer is the layer in a map or scene that displays basemap data. The data source for a basemap layer is typically a basemap service. . - Use an elevation service to define the
Scene::baseSurface(). - Create a
SceneViewand set the camera position.
Scenes3d::Scenes3d(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);
}
// Set the view (created in QML)
void Scenes3d::setSceneView(SceneQuickView* sceneView)
{
if (!sceneView || sceneView == m_sceneView)
return;
m_sceneView = sceneView;
m_sceneView->setArcGISScene(m_scene);
// create a camera
constexpr double latitude = 33.961;
constexpr double longitude = -118.808;
constexpr double altitude = 2000;
constexpr double heading = 0.0;
constexpr double pitch = 75.0;
constexpr double roll = 0.0;
const Camera camera(latitude, longitude, altitude, heading, pitch, roll);
m_sceneView->setViewpointCameraAsync(camera);
emit sceneViewChanged();
}
Display a global scene from a mobile scene package
This example displays a scene
Steps
- Create a
MobileScenePackageusing the path to a local .mspk file. - Call
MobileScenePackage::load()to load the package. - When the package loads, get the first scene from the package using the
MobileScenePackage::scenes()property. - Display the global scene in a
SceneView.
// Create scene package and connect to signals.
void Scenes3d::createScenePackage(const QString& filePath)
{
m_scenePackage = new MobileScenePackage(filePath, this);
connect(m_scenePackage, &MobileScenePackage::doneLoading, this, &Scenes3d::packageLoaded);
m_scenePackage->load();
}
// Check for errors, acquire first scene in package, set to scene view.
void Scenes3d::packageLoaded(const Error& e)
{
if (!e.isEmpty())
{
qDebug() << QString("Package load error: %1 %2").arg(e.message(), e.additionalMessage());
return;
}
if (m_scenePackage->scenes().isEmpty())
return;
m_scene = m_scenePackage->scenes().at(0);
if (m_scene && m_sceneView)
m_sceneView->setArcGISScene(m_scene);
}