ArcGIS Runtime SDK for Qt

Raster rendering rule



#include "RasterRenderingRule.h"

#include "Map.h"
#include "MapQuickView.h"
#include "RasterLayer.h"
#include "Basemap.h"
#include "ArcGISTiledLayer.h"
#include "ImageServiceRaster.h"
#include "RenderingRule.h"
#include "RenderingRuleInfo.h"

#include <QQmlProperty>
#include <QJsonObject>
#include <QJsonDocument>

using namespace Esri::ArcGISRuntime;

RasterRenderingRule::RasterRenderingRule(QQuickItem* parent /* = nullptr */):

void RasterRenderingRule::init()
  // Register the map view for QML
  qmlRegisterType<MapQuickView>("Esri.Samples", 1, 0, "MapView");
  qmlRegisterType<RasterRenderingRule>("Esri.Samples", 1, 0, "RasterRenderingRuleSample");

void RasterRenderingRule::componentComplete()

  // find QML MapView component
  m_mapView = findChild<MapQuickView*>("mapView");

  m_map = new Map(Basemap::streets(this), this);

  // set the url
  m_url = QUrl("");

  // create an image service raster
  m_imageServiceRaster = new ImageServiceRaster(m_url, this);

  // zoom to the raster's extent once it's loaded
  connect(m_imageServiceRaster, &ImageServiceRaster::doneLoading, this, [this]()
    // set the extent of the mapview to the extent defined in the image service raster's service info

    // get the rendering rule infos
    QList<RenderingRuleInfo> renderingRuleInfos = m_imageServiceRaster->serviceInfo().renderingRuleInfos();
    if (renderingRuleInfos.length() > 0)
      for (const RenderingRuleInfo& renderingRuleInfo : renderingRuleInfos)
        // populate the list with the rendering rule names
        m_renderingRuleNames <<;
      emit renderingRuleNamesChanged();

  // create a raster layer using the image service raster
  m_rasterLayer = new RasterLayer(m_imageServiceRaster, this);
  // add the raster layer to the map's operational layers

void RasterRenderingRule::applyRenderingRule(int index)
  // get the rendering rule info from the service info
  RenderingRuleInfo renderingRuleInfo = m_imageServiceRaster->serviceInfo().renderingRuleInfos().at(index);
  // create a new rendering rule with the rendering rule info
  RenderingRule* renderingRule = new RenderingRule(renderingRuleInfo, this);
  // create an image service raster
  ImageServiceRaster* isr = new ImageServiceRaster(m_url, this);
  // set the rendering rule
  // create a new raster layer using the image service raster
  RasterLayer* rasterLayer = new RasterLayer(isr, this);
  // add the raster layer to the map

In this topic
  1. Code