Fix the camera to point at and rotate around a target object.

Use case
The orbit geoelement camera controller provides control over the following camera behaviors:
- automatically track the target
- stay near the target by setting a minimum and maximum distance offset
- restrict where you can rotate around the target
- automatically rotate the camera when the target’s heading and pitch changes
- disable user interactions for rotating the camera
- animate camera movement over a specified duration
- control the vertical positioning of the target on the screen
- set a target offset (e.g.to orbit around the tail of the plane) instead of defaulting to orbiting the center of the object
How to use the sample
The sample loads with the camera orbiting an plane model. The camera is preset with a restricted camera heading and pitch, and a limited minimum and maximum camera distance set from the plane. The position of the plane on the screen is also set just below center.
Use the “Camera Heading” slider to adjust the camera heading. Select the “Allow camera distance interaction” checkbox to allow zooming in and out with the mouse/keyboard: when the checkbox is deselected the user will be unable to adjust with the camera distance.
Use the “Plane Pitch” slider to adjust the plane’s pitch. When in Center view, the plane’s pitch will change independently to that of the camera pitch.
Use the “Cockpit view” button to offset and fix the camera into the cockpit of the plane. Use the “Plane pitch” slider to control the pitch of plane: the camera will follow the pitch of the plane in this mode. In this view adjusting the camera distance is disabled. Use the “Center view” button to exit cockpit view mode and fix the camera controller on the center of the plane.
How it works
- Instantiate an
OrbitGeoElementCameraControllerwithGeoElementand camera distance as parameters. - Use
sceneView::setCameraController(OrbitCameraController)to set the camera to the scene view. - Set the heading, pitch and distance camera properties with:
orbitCameraController::setCameraHeadingOffset(double)orbitCameraController::setCameraPitchOffset(double)orbitCameraController::setCameraDistance(double)
- Set the minimum and maximum angle of heading and pitch, and minimum and maximum distance for the camera with:
orbitCameraController::setMinCameraHeadingOffset(double)orsetMaxCameraHeadingOffset(double)orbitCameraController::setMinCameraHeadingOffset(double)orsetMaxCameraPitchOffset(double)orbitCameraController::setMinCameraHeadingOffset(double)orsetMaxCameraDistance(double)
- Set the distance from which the camera is offset from the plane with:
orbitCameraController::setTargetOffsets(x, y, z, duration)orbitCameraController::setTargetOffsetX(double)orbitCameraController::setTargetOffsetY(double)orbitCameraController::setTargetOffsetZ(double)
- Set the vertical screen factor to determine where the plane appears in the scene:
orbitCameraController::setTargetVerticalScreenFactor(float)
- Animate the camera to the cockpit using
orbitCameraController::setTargetOffsetsAsync(x, y, z, duration) - Set if the camera distance will adjust when zooming or panning using mouse or keyboard (default is true):
orbitCameraController::setCameraDistanceInteractive(boolean)
- Set if the camera will follow the pitch of the plane (default is true):
orbitCameraController::setAutoPitchEnabled(boolean)
Relevant API
- OrbitGeoElementCameraController
Offline data
Read more about how to set up the sample’s offline data here.
| Link | Local Location |
|---|---|
| Bristol Plane Model | <userhome>/ArcGIS/Runtime/Data/3D/Bristol/Collada/Bristol.dae |
Tags
3D, camera, object, orbit, rotate, scene
Sample Code
// [WriteFile Name=OrbitCameraAroundObject, Category=Scenes]// [Legal]// Copyright 2019 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// http://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.// [Legal]
#ifdef PCH_BUILD#include "pch.hpp"#endif // PCH_BUILD
// sample headers#include "OrbitCameraAroundObject.h"
// ArcGIS Maps SDK headers#include "ArcGISTiledElevationSource.h"#include "AttributeListModel.h"#include "ElevationSourceListModel.h"#include "Graphic.h"#include "GraphicListModel.h"#include "GraphicsOverlay.h"#include "GraphicsOverlayListModel.h"#include "LayerSceneProperties.h"#include "MapTypes.h"#include "ModelSceneSymbol.h"#include "OrbitGeoElementCameraController.h"#include "Point.h"#include "RendererSceneProperties.h"#include "Scene.h"#include "SceneQuickView.h"#include "SceneViewTypes.h"#include "SimpleRenderer.h"#include "SpatialReference.h"#include "Surface.h"
// Qt headers#include <QFuture>#include <QStandardPaths>#include <QUuid>
using namespace Esri::ArcGISRuntime;
namespace{ // helper method to get cross platform data path QString defaultDataPath() { QString dataPath;
#ifdef Q_OS_IOS dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); #else dataPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); #endif
return dataPath; }}
OrbitCameraAroundObject::OrbitCameraAroundObject(QObject* parent /* = nullptr */): QObject(parent), m_scene(new Scene(BasemapStyle::ArcGISImageryStandard, 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);}
OrbitCameraAroundObject::~OrbitCameraAroundObject() = default;
void OrbitCameraAroundObject::init(){ // Register classes for QML qmlRegisterType<SceneQuickView>("Esri.Samples", 1, 0, "SceneView"); qmlRegisterType<OrbitCameraAroundObject>("Esri.Samples", 1, 0, "OrbitCameraAroundObjectSample");}
SceneQuickView* OrbitCameraAroundObject::sceneView() const{ return m_sceneView;}
// Set the view (created in QML)void OrbitCameraAroundObject::setSceneView(SceneQuickView* sceneView){ if (!sceneView || sceneView == m_sceneView) { return; }
m_sceneView = sceneView; m_sceneView->setArcGISScene(m_scene);
/* Scene Rendering setup */ // create a new graphics overlay and add it to the sceneview GraphicsOverlay* sceneOverlay = new GraphicsOverlay(this); sceneOverlay->setSceneProperties(LayerSceneProperties(SurfacePlacement::Relative)); m_sceneView->graphicsOverlays()->append(sceneOverlay);
// create a renderer to control the plane's orientation by its attributes SimpleRenderer* renderer3D = new SimpleRenderer(this); { //Set the renderer pitch/heading expressions, so the plane can be oriented via properties. RendererSceneProperties properties = renderer3D->sceneProperties(); properties.setPitchExpression("[PITCH]"); properties.setHeadingExpression("[HEADING]"); renderer3D->setSceneProperties(properties); } sceneOverlay->setRenderer(renderer3D);
/* Plane model Setup */ //Create a plane model. QUrl planeFileURl = QUrl(defaultDataPath() + "/ArcGIS/Runtime/Data/3D/Bristol/Collada/Bristol.dae"); ModelSceneSymbol* planeModel = new ModelSceneSymbol(planeFileURl, 1.0, this);
//Create a graphic from the plane model, positioned atop a runway. Point runwayPos = Point{6.637, 45.399, 100, SpatialReference::wgs84()}; m_planeGraphic = new Graphic(runwayPos, planeModel, this);
//Create the plane orientation attributes that are going to be used. Orient the heading 45 degs so the plane faces down the runway. m_planeGraphic->attributes()->insertAttribute("PITCH", 0.0); m_planeGraphic->attributes()->insertAttribute("HEADING", 45.0);
//Add the plane graphic to the scene. m_sceneView->graphicsOverlays()->at(0)->graphics()->append(m_planeGraphic);
/* Orbiting Camera setup */ // create the camera controller to follow the plane m_orbitCam = new OrbitGeoElementCameraController(m_planeGraphic, 50, this);
// restrict the camera's heading to stay behind the plane // Note : Since this is exposed and hooked up as a property, the heading slider in the UI will automatically adjust its bounds, try changing these values. m_orbitCam->setMinCameraHeadingOffset(-45); m_orbitCam->setMaxCameraHeadingOffset(45); emit cameraHeadingBoundsChanged();
// restrict the camera's pitch so it doesn't go completely vertical or collide with the ground m_orbitCam->setMinCameraPitchOffset(10); m_orbitCam->setMaxCameraPitchOffset(100);
// restrict the camera to stay between 10 and 1000 meters from the plane m_orbitCam->setMinCameraDistance(10); m_orbitCam->setMaxCameraDistance(100);
// position the plane a third from the bottom of the screen m_orbitCam->setTargetVerticalScreenFactor(0.33f); // don't pitch the camera when the plane pitches m_orbitCam->setAutoPitchEnabled(false);
// Forward the camera heading changed signal on to the QML property signal. // This allows the "camera heading" slider to react to changing the camera heading via mouse motion // See "onMoved" signal handler in OrbitCameraAroundObject.qml connect(m_orbitCam, &OrbitGeoElementCameraController::cameraHeadingOffsetChanged, this, &OrbitCameraAroundObject::cameraHeadingChanged);
//Apply our new orbiting camera to the scene view. m_sceneView->setCameraController(m_orbitCam);
emit sceneViewChanged();}
void OrbitCameraAroundObject::cockpitView(){ /* * Animates the camera to a cockpit view. The camera's target is offset to the cockpit (instead of the plane's * center). The camera is moved onto the target position to create a swivelling camera effect. Auto pitch is * enabled so the camera pitches when the plane pitches. */
//No zooming in/out by default in cockpit view setCamDistanceInteractionAllowed(false);
//allow the camera to get closer to the target m_orbitCam->setMinCameraDistance(0);
// animate the camera target to the cockpit instead of the center of the plane auto future = m_orbitCam->setTargetOffsetsAsync(0, -2, 1.1, 1); Q_UNUSED(future)
//The animation may rotate us over the set camera bounds based on the plane pitch, so unlock them. m_orbitCam->setMinCameraPitchOffset(-180.0); m_orbitCam->setMaxCameraPitchOffset(180.0);
//Start the camera move into the cockpit //If the camera is already tracking object pitch, don't want to animate the pitch any further, we're exactly where we should be. m_orbitCam->moveCameraAsync(-m_orbitCam->cameraDistance(), -m_orbitCam->cameraHeadingOffset(), m_orbitCam->isAutoPitchEnabled() ? 0.0 : (90 - m_orbitCam->cameraPitchOffset()) + planePitch(), 1.0).then(this, [this](bool succeeded) { if (!succeeded) return;
//once the camera is in the cockpit, only allow the camera's heading to change m_orbitCam->setMinCameraPitchOffset(90); m_orbitCam->setMaxCameraPitchOffset(90);
// pitch the camera when the plane pitches m_orbitCam->setAutoPitchEnabled(true); });
}
void OrbitCameraAroundObject::centerView(){ /* * Configures the camera controller for a "follow" view. The camera targets the center of the plane with a default * position directly behind and slightly above the plane. Auto pitch is disabled so the camera does not pitch when * the plane pitches. */
setCamDistanceInteractionAllowed(true); m_orbitCam->setAutoPitchEnabled(false); m_orbitCam->setTargetOffsetX(0); m_orbitCam->setTargetOffsetY(0); m_orbitCam->setTargetOffsetZ(0); m_orbitCam->setCameraHeadingOffset(0); m_orbitCam->setMinCameraPitchOffset(10); m_orbitCam->setMaxCameraPitchOffset(100); m_orbitCam->setCameraPitchOffset(45); m_orbitCam->setMinCameraDistance(10.0); m_orbitCam->setCameraDistance(50.0);}
// QML Property methods, (see the Q_PROPERTY declarations in header file,) for allowing the model to interact with the UI// We need to do nullptr checks here as it's entirely possible, and even expected, that these getter properties will be called by the UI// before setSceneView has been called. Objects like the camera are not initialised until then, so return sensible defaults if the object is null.bool OrbitCameraAroundObject::camDistanceInteractionAllowed() const{ return m_orbitCam != nullptr ? m_orbitCam->isCameraDistanceInteractive() : true;}
void OrbitCameraAroundObject::setCamDistanceInteractionAllowed(bool allowed){ //Check the allowed flags arn't the same on set to avoid a binding loop if ((m_orbitCam != nullptr) && (allowed != m_orbitCam->isCameraDistanceInteractive())) { m_orbitCam->setCameraDistanceInteractive(allowed); emit camDistanceInteractionAllowedChanged(); }}
double OrbitCameraAroundObject::cameraHeading() const{ return m_orbitCam != nullptr ? m_orbitCam->cameraHeadingOffset() : 0.0;}
void OrbitCameraAroundObject::setCameraHeading(double heading){ if (m_orbitCam != nullptr) { m_orbitCam->setCameraHeadingOffset(heading); emit cameraHeadingChanged(); }}
float OrbitCameraAroundObject::planePitch() const{ if(!m_planeGraphic->attributes()->containsAttribute("PITCH")) { return 0.0; }
return m_planeGraphic->attributes()->attributeValue("PITCH").toFloat();}
void OrbitCameraAroundObject::setPlanePitch(float pitch){ if (!m_planeGraphic->attributes()->containsAttribute("PITCH")) { m_planeGraphic->attributes()->insertAttribute("PITCH", pitch); } else { m_planeGraphic->attributes()->replaceAttribute("PITCH", pitch); } emit planePitchChanged();}
QPointF OrbitCameraAroundObject::cameraHeadingBounds() const{ return m_orbitCam != nullptr ? QPointF{m_orbitCam->minCameraHeadingOffset(), m_orbitCam->maxCameraHeadingOffset()} : QPointF{-45.0, 45.0};}// [WriteFile Name=OrbitCameraAroundObject, Category=Scenes]// [Legal]// Copyright 2019 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// http://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.// [Legal]
#ifndef ORBITCAMERAAROUNDOBJECT_H#define ORBITCAMERAAROUNDOBJECT_H
// Qt headers#include <QObject>#include <QPointF>
namespace Esri::ArcGISRuntime{ class Graphic; class ModelSceneSymbol; class OrbitGeoElementCameraController; class Scene; class SceneQuickView;}
Q_MOC_INCLUDE("SceneQuickView.h")
class OrbitCameraAroundObject : public QObject{ Q_OBJECT
//Property declarations for interacting with the QML UI. Q_PROPERTY(Esri::ArcGISRuntime::SceneQuickView* sceneView READ sceneView WRITE setSceneView NOTIFY sceneViewChanged) Q_PROPERTY(bool allowCamDistanceInteraction READ camDistanceInteractionAllowed WRITE setCamDistanceInteractionAllowed(bool) NOTIFY camDistanceInteractionAllowedChanged) Q_PROPERTY(float planePitch READ planePitch() WRITE setPlanePitch(float) NOTIFY planePitchChanged) Q_PROPERTY(double cameraHeading READ cameraHeading() WRITE setCameraHeading(double) NOTIFY cameraHeadingChanged) Q_PROPERTY(QPointF cameraHeadingBounds READ cameraHeadingBounds() NOTIFY cameraHeadingBoundsChanged)
public: explicit OrbitCameraAroundObject(QObject* parent = nullptr); ~OrbitCameraAroundObject();
static void init();
//Methods that can be called from the QML UI, connected to the change-view buttons in the top left of the window Q_INVOKABLE void cockpitView(); Q_INVOKABLE void centerView();
public slots: //Property setter methods allowing the QML UI to set model state, for changing plane orientation with the sliders, or toggling limits on camera zooming. void setCamDistanceInteractionAllowed(bool allowed); void setPlanePitch(float pitch); void setCameraHeading(double heading);
signals: void sceneViewChanged(); void camDistanceInteractionAllowedChanged(); void planePitchChanged(); void cameraHeadingChanged(); void cameraHeadingBoundsChanged();
private: Esri::ArcGISRuntime::SceneQuickView* sceneView() const; void setSceneView(Esri::ArcGISRuntime::SceneQuickView* sceneView);
Esri::ArcGISRuntime::Scene* m_scene = nullptr; Esri::ArcGISRuntime::SceneQuickView* m_sceneView = nullptr;
//The plane that is displayed on screen, pitch property controlled via UI Sliders. Esri::ArcGISRuntime::Graphic* m_planeGraphic = nullptr;
//Camera that orbits the plane in the scene, controlled via mouse/touch interaction or UI sliders Esri::ArcGISRuntime::OrbitGeoElementCameraController* m_orbitCam = nullptr;
//Getter property exposing whether the the orbit-camera allows distance interaction to the QML UI, as it can be toggled there. bool camDistanceInteractionAllowed() const; float planePitch() const; double cameraHeading() const; QPointF cameraHeadingBounds() const;};
#endif // ORBITCAMERAAROUNDOBJECT_H// [WriteFile Name=OrbitCameraAroundObject, Category=Scenes]// [Legal]// Copyright 2019 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// http://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.// [Legal]
import Esri.Samplesimport QtQuickimport QtQuick.Controlsimport QtQuick.Layouts
Item {
SceneView { id: view anchors.fill: parent
Component.onCompleted: { // Set the focus on SceneView to initially enable keyboard navigation forceActiveFocus(); } }
// Declare the C++ instance which creates the scene etc. and supply the view OrbitCameraAroundObjectSample { id: model sceneView: view planePitch: planePitchSlider.value }
//Camera heading slider, sits at the bottom of the screen Slider { id: cameraHeadingSlider
anchors { left: parent.left right: parent.right bottom: parent.bottom margins: 20 }
value: model.cameraHeading //Value bound to the model, so rotating the camera will update the slider. from: model.cameraHeadingBounds.x //Similarly, setting different initial bounds changes the UI automatically. Type used is QPointF for min/max, hence the x/y to: model.cameraHeadingBounds.y
//To avoid getting stuck in a binding loop for the value, update the value of the camera heading from the slider only in response to a moving slider. onMoved: { model.cameraHeading = cameraHeadingSlider.value }
//Custom slider handle that displays the current value handle: Item { x: parent.leftPadding + parent.visualPosition * (parent.availableWidth - headingHandleNub.width) y: parent.topPadding + parent.availableHeight / 2 - headingHandleNub.height / 2
Rectangle { id: headingHandleNub color: headingHandleRect.color radius: width * 0.5 width: 10 height: width } Rectangle { id: headingHandleRect height: childrenRect.height width: childrenRect.width radius: 3 x: headingHandleNub.x - width / 2 + headingHandleNub.width / 2 y: headingHandleNub.y - height
Text { id: headingValue font.pixelSize: 14 padding: 3 horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter text: Math.round(cameraHeadingSlider.value) + "\u00B0" color: "white" } } } }
Text { id: cameraHeadingLabel
anchors { horizontalCenter: cameraHeadingSlider.horizontalCenter bottom: cameraHeadingSlider.top bottomMargin: 10 }
text: "Camera Heading" color: "white" }
//Plane pitch slider, placed in the top-right of the screen Text { id: planePitchLabel
anchors { horizontalCenter: planePitchSlider.horizontalCenter bottom: planePitchSlider.top bottomMargin: 10 }
text: "Plane Pitch" color: "white" }
Slider { id: planePitchSlider
anchors { top: parent.top bottom: parent.verticalCenter right: parent.right margins: 30 }
value: 0 from: 90 to: -90 orientation: Qt.Vertical
//Custom slider handle that displays the current value handle: Item { x: planePitchSlider.leftPadding + planePitchSlider.availableWidth / 2 - pitchHandleNub.width / 2 y: planePitchSlider.topPadding + planePitchSlider.visualPosition * (planePitchSlider.availableHeight - pitchHandleNub.height)
Rectangle { id: pitchHandleNub color: pitchHandleRect.color radius: width * 0.5 width: 10 height: width } Rectangle { id: pitchHandleRect height: childrenRect.height width: childrenRect.width radius: 3 x: pitchHandleNub.x - width y: pitchHandleNub.y - height/2 + pitchHandleNub.height/2
Text { id: pitchValue font.pixelSize: 14 padding: 3 horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter text: Math.round(planePitchSlider.value) + "\u00B0" color: "white" } } } }
//View change buttons / allow cam interaction checkbox placed in the top-left of the screen. Rectangle { anchors { left: parent.left top: parent.top }
height: childrenRect.height width: childrenRect.width color: Qt.rgba(0.2, 0.2, 0.2, 0.65)
Column { spacing: 10 padding: 10 Button { text: "Cockpit View" onClicked: { model.cockpitView(); allowCamDistanceInteractionCheckBox.enabled = false; allowCamDistanceInteractionCheckBoxText.color = "gray"; } }
Button { text: "Center View" onClicked: { model.centerView(); allowCamDistanceInteractionCheckBox.enabled = true; allowCamDistanceInteractionCheckBoxText.color = "white"; } }
Row { anchors { left: parent.left }
CheckBox { id: allowCamDistanceInteractionCheckBox checked: model.allowCamDistanceInteraction onCheckedChanged: model.allowCamDistanceInteraction = checked }
Text { id: allowCamDistanceInteractionCheckBoxText anchors { verticalCenter: allowCamDistanceInteractionCheckBox.verticalCenter } text: "Allow camera\ndistance interaction" color: "white" } } } }}// [Legal]// Copyright 2019 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// http://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.// [Legal]
// sample headers#include "OrbitCameraAroundObject.h"
// ArcGIS Maps SDK headers#include "ArcGISRuntimeEnvironment.h"
// Qt headers#include <QDir>#include <QGuiApplication>#include <QQmlApplicationEngine>#include <QSurfaceFormat>
// Platform specific headers#ifdef Q_OS_WIN#include <Windows.h>#endif
#define STRINGIZE(x) #x#define QUOTE(x) STRINGIZE(x)
int main(int argc, char *argv[]){ Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setUseLegacyAuthentication(false);#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) // Linux requires 3.2 OpenGL Context // in order to instance 3D symbols QSurfaceFormat fmt = QSurfaceFormat::defaultFormat(); fmt.setVersion(3, 2); QSurfaceFormat::setDefaultFormat(fmt);#endif
QGuiApplication app(argc, argv); app.setApplicationName(QString("OrbitCameraAroundObject"));
// Use of ArcGIS location services, such as basemap styles, geocoding, and routing services, // requires an access token. For more information see // https://links.esri.com/arcgis-runtime-security-auth.
// The following methods grant an access token:
// 1. User authentication: Grants a temporary access token associated with a user's ArcGIS account. // To generate a token, a user logs in to the app with an ArcGIS account that is part of an // organization in ArcGIS Online or ArcGIS Enterprise.
// 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("");
if (accessToken.isEmpty()) { qWarning() << "Use of ArcGIS location services, such as the basemap styles service, requires" << "you to authenticate with an ArcGIS account or set the API Key property."; } else { Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setApiKey(accessToken); }
// Initialize the sample OrbitCameraAroundObject::init();
QString arcGISRuntimeImportPath = QUOTE(ARCGIS_RUNTIME_IMPORT_PATH);
#if defined(LINUX_PLATFORM_REPLACEMENT) // on some linux platforms the string 'linux' is replaced with 1 // fix the replacement paths which were created QString replaceString = QUOTE(LINUX_PLATFORM_REPLACEMENT); arcGISRuntimeImportPath = arcGISRuntimeImportPath.replace(replaceString, "linux", Qt::CaseSensitive);#endif
// Initialize application view QQmlApplicationEngine engine; // Add the import Path engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml")); // Add the Runtime and Extras path engine.addImportPath(arcGISRuntimeImportPath);
// Set the source engine.load(QUrl("qrc:/Samples/Scenes/OrbitCameraAroundObject/main.qml"));
return app.exec();}// Copyright 2019 ESRI//// All rights reserved under the copyright laws of the United States// and applicable international laws, treaties, and conventions.//// You may freely redistribute and use this sample code, with or// without modification, provided you include the original copyright// notice and use restrictions.//// See the Sample code usage restrictions document for further information.//
import QtQuick.Controlsimport Esri.Samples
ApplicationWindow { visible: true width: 800 height: 600
OrbitCameraAroundObject { anchors.fill: parent }}