Displaying a Basemap in a Qt C++ Application Using ArcGIS Map SDK

arcgis-map-sdk-Manya Technologies

Geospatial applications have become critical in a wide variety of industries—from urban planning and logistics to defense and environmental monitoring. Visualizing geospatial data efficiently and interactively can be challenging, but modern mapping SDKs like the ArcGIS Map SDK for Qt provide powerful tools to make this easier. In this blog, we’ll explore how to display a basemap in a Qt C++ application using ArcGIS Map SDK, step by step.


Why ArcGIS Map SDK for Qt?

ArcGIS Map SDK is designed for building high-performance mapping applications on desktop, mobile, and embedded devices. Key advantages include:

  • Rich Basemap Options: ArcGIS provides a variety of basemap styles, such as streets, satellite imagery, topographic, and OpenStreetMap (OSM).
  • Cross-Platform Support: Compatible with Windows, Linux, and macOS via Qt.
  • Enterprise Ready: Integration with ArcGIS services and geospatial data.
  • Community & Industry Recognition: Used globally in GIS, defense, urban planning, and logistics projects.

Use Case

Suppose you are developing a desktop GIS tool to visualize live tracking data, drone flight paths, or city infrastructure. The first step is often to load a reliable basemap as a reference layer for all geospatial data. ArcGIS Map SDK makes this process simple and fast in Qt.


Getting Started: Code Example

Below is a minimal example to display a basemap in a Qt C++ application using ArcGIS Map SDK. Note: Never hardcode your API key in production—use environment variables or secure storage.

main.cpp

#include <QApplication>
#include "MainWindow.h"
#include <ArcGISRuntimeEnvironment.h>

int main(int argc, char *argv[])
{
    QApplication application(argc, argv);

    // Disable legacy authentication
    ArcGISRuntimeEnvironment::setUseLegacyAuthentication(false);

    // API key setup (replace with environment variable or secure storage in production)
    const QString accessToken = QString("YOUR_ARCGIS_API_KEY_HERE");

    if (accessToken.isEmpty()) {
        qWarning() << "ArcGIS services, such as basemap styles, require authentication.";
    } else {
        ArcGISRuntimeEnvironment::setApiKey(accessToken);
    }

    MainWindow w;
    w.show();

    return application.exec();
}

MainWindow.cpp

#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <Map.h>
#include <MapGraphicsView.h>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Create a map using the OpenStreetMap basemap style
    m_map = new Esri::ArcGISRuntime::Map(Esri::ArcGISRuntime::BasemapStyle::OsmStandard, this);

    // Create the widget view
    m_mapView = new Esri::ArcGISRuntime::MapGraphicsView(this);

    // Set the map to the map view
    m_mapView->setMap(m_map);

    // Set map view as the central widget
    setCentralWidget(m_mapView);
}

And in your MainWindow.h:

private:
    Esri::ArcGISRuntime::Map *m_map = nullptr;
    Esri::ArcGISRuntime::MapGraphicsView *m_mapView = nullptr;

How It Works

  1. ArcGISRuntimeEnvironment::setApiKey(): Authenticates your application to access ArcGIS services.
  2. Map & BasemapStyle: Creates a map object with the desired basemap style.
  3. MapGraphicsView: A QWidget-based component that renders the map inside your Qt application.
  4. Central Widget Integration: Sets the map view as the main widget of the window, so it automatically occupies the full client area of the QMainWindow.

This approach ensures a responsive, fully interactive map integrated into your Qt C++ desktop application.


Conclusion

Using ArcGIS Map SDK with Qt allows developers to create rich, interactive geospatial applications with minimal code. Whether for urban planning, defense, logistics, or research, ArcGIS Map SDK provides the performance, reliability, and flexibility needed for modern GIS tools.

By following this guide, you can quickly set up a basemap, authenticate securely, and prepare your application for advanced geospatial features like layer overlays, routing, and live tracking.

If you’re interested in a full-fledged GIS solution, check out our flagship product PrithviGIS – a powerful QGIS-based platform for real-time geospatial visualization. PrithviGIS is an indigenous GIS development in India.

Check out our Live Aircraft Simulation using CesiumJS.

Scroll to Top