Learn how to find a route and directions with the route service

Routing is the process of finding the path from an origin
In this tutorial, you define an origin and destination by clicking on the map. These values are used to get a route and directions from the route service. The directions are also displayed on the map.
Prerequisites
Before starting this tutorial:
-
You need an ArcGIS Location Platform or ArcGIS Online account.
-
Your system meets the system requirements.
-
The ArcGIS Maps SDK for Qt, version 300.1.0 or later is installed.
-
The Qt 6.8.2 software development framework or later is installed.
Set up authentication
To access the secure ArcGIS location services
You can implement API key authentication or user authentication in this tutorial. Compare the differences below:
API key authentication
- Users are not required to sign in.
- Requires creating an API key credential
API key credentials are an item that contains the parameters used to create and manage long-lived access tokens for API key authentication. They are a type of developer credential. with the correct privileges. - API keys
An API key is a long-lived access token created using API key credentials. They are valid for up to one year and are typically embedded directly into client applications. are long-lived access tokens. - Service usage is billed to the API key owner/developer.
- Simplest authentication method to implement.
- Recommended approach for new ArcGIS developers.
Learn more in API key authentication.
User authentication
- Users are required to sign in with an ArcGIS account
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. . - User accounts must have privilege
Privileges are a set of permissions assigned to ArcGIS accounts, developer credentials, and applications that grant access to secure resources and functionality in ArcGIS. to access the ArcGIS servicesA service, also known as an ArcGIS service, is software that supports an ArcGIS REST API and provides geospatial functionality or data. A service can be hosted by Esri or in ArcGIS Enterprise. used in application. - Requires creating OAuth credentials
OAuth credentials are an item that contains parameters required to implement user authentication or app authentication, including a .client_id,client_secret, and redirect URIs. They are a type of developer credential. - Application uses a redirect URL and client ID.
- Service usage is billed to the organization of the user signed into the application.
Learn more in User authentication.
To complete this tutorial, click on the tab in the switcher below for your authentication type of choice, either API key authentication or User authentication.
Create a new API key access token
-
Complete the Create an API key tutorial and create an API key with the following privilege(s)
Privileges are a set of permissions assigned to ArcGIS accounts, developer credentials, and applications that grant access to secure resources and functionality in ArcGIS. :- Privileges
- Location services > Basemaps
- Location services > Routing
- Privileges
-
Copy and paste the API key access token into a safe location. It will be used in a later step.
Create new OAuth credentials to access the secure resources used in this tutorial.
-
Complete the Create OAuth credentials for user authentication tutorial to obtain a Client ID and Redirect URL.
A
Client IDuniquely identifies your app on the authenticating server. If the server cannot find an app with the provided Client ID, it will not proceed with authentication.The
Redirect URL(also referred to as a callback url) is used to identify a response from the authenticating server when the system returns control back to your app after an OAuth login. Since it does not necessarily represent a valid endpoint that a user could navigate to, the redirect URL can use a custom scheme, such asmy-app://auth. It is important to make sure the redirect URL used in your app’s code matches a redirect URL configured on the authenticating server. -
Copy and paste the Client ID and Redirect URL into a safe location. They will be used in a later step.
All users that access this application need account privileges
Develop or Download
You have two options for completing this tutorial:
Option 1: Develop the code
To start the tutorial, complete the Display a map tutorial. This creates a map to display the Santa Monica Mountains in California using the topographic basemap from the ArcGIS Basemap Styles service
Open a Qt Creator project
- Open the project you created by completing the Display a map tutorial.
- Continue with the following instructions to find a route and directions with the ArcGIS Routing service
A routing service is a service that uses network analysis and streets data to calculate the most effective path and turn-by-turn directions on a street network, optimize fleet routing and deliveries, find the closest facilities, calculate service areas, and more. It is hosted by Esri as the ArcGIS Routing service and can also be hosted in ArcGIS Enterprise. .
Declare classes, functions, variables, enumerations and signals
-
In the Display_a_map project, double click on Headers > Display_a_map.h to open the file. Add the four class declarations shown.
Display_a_map.hnamespace Esri::ArcGISRuntime {class Map;class MapQuickView;class Graphic;class GraphicsOverlay;class PictureMarkerSymbol;class RouteTask; -
Continuing in the Display_a_map.h file, create an enum to monitor user route selections and maintain the route builder status. This will be initialized in Display_a_map.cpp in a later step.
Display_a_map.hclass Graphic;class GraphicsOverlay;class PictureMarkerSymbol;class RouteTask;} // namespace Esri::ArcGISRuntimeenum RouteBuilderStatus{NotStarted,SelectedStart,SelectedStartAndEnd,}; -
Add an
#includestatement, class declaration, and a Meta Object Compiler (MOC) to add an include that exposes theQAbstractListModel.Display_a_map.henum RouteBuilderStatus{NotStarted,SelectedStart,SelectedStartAndEnd,};#include <QObject>#include "RouteParameters.h"class QAbstractListModel;Q_MOC_INCLUDE("QAbstractListModel")Q_MOC_INCLUDE("MapQuickView.h") -
Use
Q_PROPERTYto create a member variablem_directions.Display_a_map.hclass Display_a_map : public QObject{Q_OBJECTQ_PROPERTY(Esri::ArcGISRuntime::MapQuickView* mapView READ mapView WRITE setMapView NOTIFY mapViewChanged)Q_PROPERTY(QAbstractListModel* directions MEMBER m_directions NOTIFY directionsChanged) -
Add the following signal declaration; this will be used to prompt updates to route directions.
Display_a_map.hpublic:explicit Display_a_map(QObject* parent = nullptr);~Display_a_map() override;signals:void mapViewChanged();void directionsChanged(); -
Declare the following private methods.
Display_a_map.hprivate:Esri::ArcGISRuntime::MapQuickView* mapView() const;void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView);void setupViewpoint();void setupRouteTask();void findRoute();void resetState(); -
Finally in the Display_a_map.h file, declare and initialize the following pointers, object, and enumeration. Then save the file.
Display_a_map.hvoid setupRouteTask();void findRoute();void resetState();Esri::ArcGISRuntime::Map* m_map = nullptr;Esri::ArcGISRuntime::MapQuickView* m_mapView = nullptr;Esri::ArcGISRuntime::GraphicsOverlay* m_graphicsOverlay = nullptr;Esri::ArcGISRuntime::RouteTask* m_routeTask = nullptr;Esri::ArcGISRuntime::Graphic* m_startGraphic = nullptr;Esri::ArcGISRuntime::Graphic* m_endGraphic = nullptr;Esri::ArcGISRuntime::Graphic* m_lineGraphic = nullptr;QAbstractListModel* m_directions = nullptr;Esri::ArcGISRuntime::RouteParameters m_routeParameters;RouteBuilderStatus m_currentState;
Include header files to access needed classes
-
In the Qt project, double click on Sources > Display_a_map.cpp to open the file. Add
#includestatements for the classes shown.Display_a_map.cpp#include "Display_a_map.h"#include "Map.h"#include "MapTypes.h"#include "MapQuickView.h"#include "Point.h"#include "Viewpoint.h"#include "SpatialReference.h"#include <QFuture>#include "DirectionManeuverListModel.h"#include "Graphic.h"#include "GraphicListModel.h"#include "GraphicsOverlay.h"#include "GraphicsOverlayListModel.h"#include "Polyline.h"#include "RouteTask.h"#include "RouteResult.h"#include "RouteParameters.h"#include "Route.h"#include "SimpleLineSymbol.h"#include "SimpleMarkerSymbol.h"#include "Stop.h"#include "Symbol.h"#include "SymbolTypes.h"#include <QGeoPositionInfoSource>#include <QList>#include <QUrl>#include <QUuid>
Update the constructor
-
Continuing to edit the Display_a_map.cpp file, update the constructor as shown. Set
BasemapStyletoArcGISStreetsand initialize theRouteBuilderStatusenumeration. Add an ending comma to the line for them_map(new Map(BasemapStyle::ArcGISStreets, this))member variable (yellow highlighted line) and add a new member variable form_currentState(RouteBuilderStatus::NotStarted)(green highlighted line).Display_a_map.cppDisplay_a_map::Display_a_map(QObject* parent /* = nullptr */):QObject(parent),m_map(new Map(BasemapStyle::ArcGISStreets, this)),m_currentState(RouteBuilderStatus::NotStarted) -
Call the
setupRouteTask()method within the constructor. This will be populated in a later step.Display_a_map.cppDisplay_a_map::Display_a_map(QObject* parent /* = nullptr */):QObject(parent),m_map(new Map(BasemapStyle::ArcGISStreets, this)),m_currentState(RouteBuilderStatus::NotStarted){setupRouteTask();
Change the map’s view point
-
Continuing to edit the Display_a_map.cpp file, in
setupViewpoint()method change the 2 lines for the map’sPointandViewpointto place the map over over downtown Los Angeles (highlighted in yellow).Display_a_map.cppMapQuickView* Display_a_map::mapView() const{return m_mapView;}void Display_a_map::setupViewpoint(){const Point center(-118.24532, 34.05398, SpatialReference::wgs84());const Viewpoint viewpoint(center, 144447.638572);
Change setupViewpoint() to respond to mouse clicks and find the route
-
Continuing to edit the Display_a_map.cpp file, add a
connectstatement tosetupViewpoint()to detect user mouse clicks, set and display point graphics, respond to the first and second click (using theswitchstatement), and callfindRouteon the second mouse click.Display_a_map.cppvoid Display_a_map::setupViewpoint(){const Point center(-118.24532, 34.05398, SpatialReference::wgs84());const Viewpoint viewpoint(center, 144447.638572);m_mapView->setViewpointAsync(viewpoint);connect(m_mapView, &MapQuickView::mouseClicked, this, [this](QMouseEvent& mouse){const Point mapPoint = m_mapView->screenToLocation(mouse.position().x(), mouse.position().y());switch (m_currentState){case RouteBuilderStatus::NotStarted:resetState();m_currentState = RouteBuilderStatus::SelectedStart;m_startGraphic->setGeometry(mapPoint);break;case RouteBuilderStatus::SelectedStart:m_currentState = RouteBuilderStatus::SelectedStartAndEnd;m_endGraphic->setGeometry(mapPoint);findRoute();break;case RouteBuilderStatus::SelectedStartAndEnd:// Ignore touches while routing is in progressbreak;}});
Create route graphics
-
Continuing to edit the Display_a_map.cpp file, add code to
setupViewpoint()to create the route’s starting pointGraphic, determined by the user’s first mouse click. This consists of aSimpleLineSymbol, color blue, size 2, that outlines aSimpleMarkerSymbol, diamond shaped and orange in color. Create the route’s ending pointGraphic, determined by the user’s second mouse click. This consists of aSimpleLineSymbol, color red, size 2, that outlines aSimpleMarkerSymbol, square shaped and green in color. Create a lineGraphicconnecting the route’s starting and ending points using aSimpleLineSymbol, color blue, size 4. Then append the starting point graphic, ending point graphic, and route line graphic to aGraphicsOverlay.Display_a_map.cppcase RouteBuilderStatus::SelectedStartAndEnd:// Ignore touches while routing is in progressbreak;}});m_graphicsOverlay = new GraphicsOverlay(this);m_mapView->graphicsOverlays()->append(m_graphicsOverlay);SimpleLineSymbol* startOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("blue"), 2/*width*/, this);SimpleMarkerSymbol* startSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Diamond, QColor("orange"), 12/*width*/, this);startSymbol->setOutline(startOutlineSymbol);m_startGraphic = new Graphic(this);m_startGraphic->setSymbol(startSymbol);SimpleLineSymbol* endOutlineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("red"), 2/*width*/, this);SimpleMarkerSymbol* endSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Square, QColor("green"), 12/*width*/, this);endSymbol->setOutline(endOutlineSymbol);m_endGraphic = new Graphic(this);m_endGraphic->setSymbol(endSymbol);SimpleLineSymbol* lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("blue"), 4/*width*/, this);m_lineGraphic = new Graphic(this);m_lineGraphic->setSymbol(lineSymbol);m_graphicsOverlay->graphics()->append(QList<Graphic*> {m_startGraphic, m_endGraphic, m_lineGraphic});}
Create the setRouteTask() method
A task makes a request to a serviceRouteTask class to access a routing serviceRouteTask with a string URL to reference the routing service.
-
Continuing to edit the Display_a_map.cpp file, implement the
setRouteTask()method. Point theRouteTaskto an online service. Call the create default parameters async method obtain the route parameters.Display_a_map.cppvoid Display_a_map::setupRouteTask(){// create the route task pointing to an online servicem_routeTask = new RouteTask(QUrl("https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World"), this);// Create the default parameters which will load the route task implicitly.m_routeTask->createDefaultParametersAsync().then(this,[this](const RouteParameters& routeParameters){// Store the resulting route parameters.m_routeParameters = routeParameters;});}
Create the findRoute() method
-
Continuing to edit the Display_a_map.cpp file, implement the
findRoute()method. Add code to first confirm thatRouteTaskhas loaded andRouteParametersis not empty. Then setRouteParametersto return directions, and clear stops from previous routes. Then createStopobjects for the route from the geometries of the start and end graphics, and pass those toRouteParameters. CallsolveRouteAsync(), passing inRouteParameters. With the route completed, set the route graphic’s geometry and resetRouteBuilderStatusto prepare for a new route task. Then display the route directions.Display_a_map.cppvoid Display_a_map::findRoute(){if (m_routeTask->loadStatus() != LoadStatus::Loaded || m_routeParameters.isEmpty())return;// Set parameters to return directions.m_routeParameters.setReturnDirections(true);// Clear previous stops from the parameters.m_routeParameters.clearStops();// Set the stops to the parameters.const Stop stop1(Point(m_startGraphic->geometry()));const Stop stop2(Point(m_endGraphic->geometry()));m_routeParameters.setStops(QList<Stop> { stop1, stop2 });// Solve the route with the parameters.m_routeTask->solveRouteAsync(m_routeParameters).then(this,[this](const RouteResult& routeResult){// Add the route graphic once the solve completes.const Route generatedRoute = routeResult.routes().at(0);m_lineGraphic->setGeometry(generatedRoute.routeGeometry());m_currentState = RouteBuilderStatus::NotStarted;// Set the direction maneuver list model.m_directions = generatedRoute.directionManeuvers(this);emit directionsChanged();});}
Create the resetState() method
This method resets all graphics and directions, and the RouteBuilderStatus enumeration. This happens at the beginning of every new route task.
-
Continuing to edit the Display_a_map.cpp file, reset all graphics with empty
Pointobjects, setm_directionstonullptr, and resetRouteBuilderStatus. Then save the file.Display_a_map.cppvoid Display_a_map::resetState(){m_startGraphic->setGeometry(Point());m_endGraphic->setGeometry(Point());m_lineGraphic->setGeometry(Point());m_directions = nullptr;m_currentState = RouteBuilderStatus::NotStarted;}
Create the GUI
-
In the Qt project, double click on Resources > qml\qml.qrc > /qml > Display_a_mapForm.qml to open the file. Add the following import.
display_a_mapForm.qmlimport QtQuickimport QtQuick.Controlsimport Esri.Display_a_mapimport QtQuick.Shapes -
Add the code highlighted below in green. This builds out the application GUI and displays the route and route directions.
display_a_mapForm.qml// Declare the C++ instance which creates the map etc. and supply the view.Display_a_map {id: modelmapView: view}// Create window for displaying the route directions.Rectangle {id: directionWindowanchors {right: parent.righttop: parent.topmargins: 5}radius: 5visible: model.directionswidth: Qt.platform.os === "ios" || Qt.platform.os === "android" ? 250 : 350height: parent.height / 2color: "#FBFBFB"clip: trueListView {id: directionsViewanchors {fill: parentmargins: 5}header: Component {Text {height: 40text: "Directions:"font.pixelSize: 22}}// Set the model to the DirectionManeuverListModel returned from the route.model: model.directionsdelegate: directionDelegate}}Component {id: directionDelegateRectangle {id: rectwidth: parent.widthheight: textDirections.heightcolor: directionWindow.color// separator for directionsShape {height: 2ShapePath {strokeWidth: 1strokeColor: "darkgrey"strokeStyle: ShapePath.SolidLinestartX: 20; startY: 0PathLine { x: parent.width - 20 ; y: 0 }}}Text {id: textDirectionstext: qsTr("%1 (%2 miles)".arg(directionText).arg((length * 0.00062137).toFixed(2)))wrapMode: Text.WordWrapanchors {leftMargin: 5left: parent.leftright: parent.right}}}}
Set developer credentials
For the final steps of this tutorial, click the tab below that corresponds to the authentication type (API key authentication or User authentication) that you chose when you completed the Display a map tutorial.
Be sure to also provide the same authentication (API key or user authentication Client ID/Redirect URL) that you used for the Display a map tutorial.
Set the API Key
-
In the project Sources folder of Qt Creator, open the main.cpp file.
-
Modify the code to set the
accessTokenusing your API key access token (highlighted in yellow).main.cpp// 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{ArcGISRuntimeEnvironment::setApiKey(accessToken);} -
Save the main.cpp file.
Best Practice: The access token is stored directly in the code as a convenience for this tutorial. Do not store credentials directly in source code in a production environment.
Set path to the Qt Toolkit in the project
In the project Sources folder of Qt Creator, open the Display_a_map.pro file and locate the following lines and update PATH_TO_TOOLKIT variable with the path of the toolkitcpp.pri file (highlighted in yellow) or the OAuth dialog will not appear to enter your user credentials. Then save the file.
ARCGIS_RUNTIME_VERSION = 300.1.0include($$PWD/arcgisruntime.pri)
# TODO: You need to replace the <path_to_toolkit_repo> with a valid location where the Qt Toolkit# resides on your system, example: C:/arcgis-maps-sdk-toolkit-qt/uitools/toolkitcpp/toolkitcpp.pri# This block determines whether you've cloned your toolkitPATH_TO_TOOLKIT = "<path_to_toolkit_repo>/uitools/toolkitcpp/toolkitcpp.pri"
exists($${PATH_TO_TOOLKIT}) { message("Toolkit found") DEFINES += TOOLKIT_FOUND
# include the toolkitcpp.pri, which contains all the toolkit resources include($${PATH_TO_TOOLKIT})
qtHaveModule(webenginequick) { QT += webenginequick }} else { message("Toolkit not found in provided path. Either set PATH_TO_TOOLKIT or use an API Key")}Set developer credentials in the solution
In the project Sources folder of Qt Creator, open the Display_a_map.cpp file.
Set your values for the REDIRECT_URL and the CLIENT_ID strings (highlighted in yellow). Then save the file.
{
#ifdef TOOLKIT_FOUND
// Define the Redirect URL string obtained when creating the OAuth credentials. // TODO: You need to replace the "REDIRECT_URL" with your own valid string, // ex: "urn:ietf:wg:oauth:2.0:oob" const auto qStringRedirectUrl = QString{"REDIRECT_URL"};
// Define the URL of the portal to authenticate with. const QUrl qUrlPortal = QUrl{"https://www.arcgis.com/"};
// Define a unique identifier associated with an application registered with the // portal that assists with client/server OAuth authentication. // TODO: You need to replace the "CLIENT_ID" with your own valid string. const QString qStringClientId = QString{"CLIENT_ID"};
// Create a new OAuth user configuration using: the Url to mapping web service, the Client ID // string, and the Redirect Url string. auto* oAuthUserConfiguration = new OAuthUserConfiguration(qUrlPortal, qStringClientId, qStringRedirectUrl, this);
// Call the Toolkit's OAuthUserConfigurationManager static `addConfiguration` // method to use the OAuth dialog. This will tell the Authenticator to use OAuth for the provided configuration. Toolkit::OAuthUserConfigurationManager::addConfiguration(oAuthUserConfiguration);#endif // TOOLKIT_FOUNDPress Ctrl + R to run the app.
The map should support two clicks to create an origin and destination point and then use the route service
Alternatively, you can download the tutorial solution, as follows.
Option 2: Download the solution
-
Click the
Download solutionlink underSolutionand unzip the file to a location on your machine. -
Open the .pro project file in Qt Creator.
Since the downloaded solution does not contain authentication credentials, you must add the developer credentials that you created in the Set up authentication section.
For the final steps of this tutorial, click the tab below that corresponds to the authentication type (API key authentication or User authentication) that you chose when you completed the Display a map tutorial.
Be sure to also provide the same authentication (API key or user authentication Client ID/Redirect URL) that you used for the Display a map tutorial.
Set the API Key
-
In the project Sources folder of Qt Creator, open the main.cpp file.
-
Modify the code to set the
accessTokenusing your API key access token (highlighted in yellow).main.cpp// 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{ArcGISRuntimeEnvironment::setApiKey(accessToken);} -
Save main.cpp file.
Best Practice: The access token is stored directly in the code as a convenience for this tutorial. Do not store credentials directly in source code in a production environment.
Set path to the Qt Toolkit in the project
In the project Sources folder of Qt Creator, open the Display_a_map.pro file and locate the following lines and update PATH_TO_TOOLKIT variable with the path of the toolkitcpp.pri file (highlighted in yellow) or the OAuth dialog will not appear to enter your user credentials. Then save the file.
ARCGIS_RUNTIME_VERSION = 300.1.0include($$PWD/arcgisruntime.pri)
# TODO: You need to replace the <path_to_toolkit_repo> with a valid location where the Qt Toolkit# resides on your system, example: C:/arcgis-maps-sdk-toolkit-qt/uitools/toolkitcpp/toolkitcpp.pri# This block determines whether you've cloned your toolkitPATH_TO_TOOLKIT = "<path_to_toolkit_repo>/uitools/toolkitcpp/toolkitcpp.pri"
exists($${PATH_TO_TOOLKIT}) { message("Toolkit found") DEFINES += TOOLKIT_FOUND
# include the toolkitcpp.pri, which contains all the toolkit resources include($${PATH_TO_TOOLKIT})
qtHaveModule(webenginequick) { QT += webenginequick }} else { message("Toolkit not found in provided path. Either set PATH_TO_TOOLKIT or use an API Key")}Set developer credentials in the solution
-
In the project Sources folder of Qt Creator, open the Display_a_map.cpp file.
-
Set your values for the REDIRECT_URL and the CLIENT_ID strings (highlighted in yellow). Then save the file.
{
#ifdef TOOLKIT_FOUND
// Define the Redirect URL string obtained when creating the OAuth credentials. // TODO: You need to replace the "REDIRECT_URL" with your own valid string, // ex: "urn:ietf:wg:oauth:2.0:oob" const auto qStringRedirectUrl = QString{"REDIRECT_URL"};
// Define the URL of the portal to authenticate with. const QUrl qUrlPortal = QUrl{"https://www.arcgis.com/"};
// Define a unique identifier associated with an application registered with the // portal that assists with client/server OAuth authentication. // TODO: You need to replace the "CLIENT_ID" with your own valid string. const QString qStringClientId = QString{"CLIENT_ID"};
// Create a new OAuth user configuration using: the Url to mapping web service, the Client ID // string, and the Redirect Url string. auto* oAuthUserConfiguration = new OAuthUserConfiguration(qUrlPortal, qStringClientId, qStringRedirectUrl, this);
// Call the Toolkit's OAuthUserConfigurationManager static `addConfiguration` // method to use the OAuth dialog. This will tell the Authenticator to use OAuth for the provided configuration. Toolkit::OAuthUserConfigurationManager::addConfiguration(oAuthUserConfiguration);#endif // TOOLKIT_FOUNDRun the app
Press Ctrl + R to run the app.
The map should support two clicks to create an origin and destination point and then use the route service
What’s next?
Learn how to use additional API features, ArcGIS location services, and ArcGIS tools in these tutorials: