UniqueValueRenderer Class

  • UniqueValueRenderer
  • class Esri::ArcGISRuntime::UniqueValueRenderer

    A unique value renderer symbolizes geoelements with a distinct symbol for each unique data value in an attribute. More...

    Header: #include <UniqueValueRenderer.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::Renderer

    Public Functions

    UniqueValueRenderer(QObject *parent = nullptr)
    UniqueValueRenderer(const QString &defaultLabel, Esri::ArcGISRuntime::Symbol *symbol, const QStringList &fieldNames, const QList<Esri::ArcGISRuntime::UniqueValue *> &uniqueValues, QObject *parent = nullptr)
    virtual ~UniqueValueRenderer() override
    QString defaultLabel() const
    Esri::ArcGISRuntime::Symbol *defaultSymbol() const
    QStringList fieldNames() const
    void setDefaultLabel(const QString &label)
    void setDefaultSymbol(Esri::ArcGISRuntime::Symbol *symbol)
    void setFieldNames(const QStringList &fieldNames)
    Esri::ArcGISRuntime::UniqueValueListModel *uniqueValues() const

    Detailed Description

    A unique value renderer contains a collection of uniqueValues. Each UniqueValue has a UniqueValue::symbol and a collection of UniqueValue::values to define a value or combination of values.

    This is typically used to visualize categories or data types. For example, you can use a unique value renderer to symbolize zoning designations: yellow for "Residential", purple for "Industrial", and green for both "Forests" and "Open land".

    Example:

    Apply a UniqueValueRenderer to a point feature layer repesenting California cities:

    // Create the unique values for the different cities in California
    UniqueValue* uniqueValue1 = new UniqueValue("Los Angeles", "The City of Los Angeles", QVariantList() << "Los Angeles", new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Triangle, QColor(Qt::green), 4.0, this), this);
    UniqueValue* uniqueValue2 = new UniqueValue("San Francisco", "The City of San Francisco", QVariantList() << "San Francisco", new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Circle, QColor(Qt::red), 5.0, this), this);
    UniqueValue* uniqueValue3 = new UniqueValue("San Diego", "The City of San Diego", QVariantList() << "San Diego", new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Cross, QColor(Qt::blue), 8.0, this), this);
    UniqueValue* uniqueValue4 = new UniqueValue("San Jose", "The City of San Jose", QVariantList() << "San Jose", new SimpleMarkerSymbol(SimpleMarkerSymbolStyle::Diamond, QColor(Qt::yellow), 2.0, this), this);
    
    // Add the unique values to the renderer
    UniqueValueRenderer* uniqueRenderer = new UniqueValueRenderer("Unknown city", new SimpleMarkerSymbol(this), QStringList() << "CityName", QList<UniqueValue*>() << uniqueValue1 << uniqueValue2 << uniqueValue3 << uniqueValue4, this);
    
    // Create a feature layer and apply the renderer to the layer
    ServiceFeatureTable* featureTable = new ServiceFeatureTable(serviceUrl, this);
    FeatureLayer* featureLayer = new FeatureLayer(featureTable, this);
    featureLayer->setRenderer(uniqueRenderer);

    See also UniqueValue and UniqueValueListModel.

    Member Function Documentation

    [explicit] UniqueValueRenderer::UniqueValueRenderer(QObject *parent = nullptr)

    Creates a new empty unique value renderer.

    • parent - The optional parent QObject.

    UniqueValueRenderer::UniqueValueRenderer(const QString &defaultLabel, Esri::ArcGISRuntime::Symbol *symbol, const QStringList &fieldNames, const QList<Esri::ArcGISRuntime::UniqueValue *> &uniqueValues, QObject *parent = nullptr)

    Creates a new unique value renderer object.

    • defaultLabel - The label used for the default symbol.
    • symbol - The default symbol for values that don't match any of the unique values.
    • fieldNames - A collection of the field names/attribute keys that the unique values apply to.
    • uniqueValues - A collection of unique values used by the renderer to select a symbol.
    • parent - The optional parent QObject.

    [override virtual] UniqueValueRenderer::~UniqueValueRenderer()

    Destructor.

    QString UniqueValueRenderer::defaultLabel() const

    Returns the label used for the default symbol.

    See also setDefaultLabel.

    Esri::ArcGISRuntime::Symbol *UniqueValueRenderer::defaultSymbol() const

    Returns the default symbol for values that don't match any of the unique values.

    See also setDefaultSymbol.

    QStringList UniqueValueRenderer::fieldNames() const

    Returns a list of the field names/attribute keys that the unique values apply to.

    See also setFieldNames.

    void UniqueValueRenderer::setDefaultLabel(const QString &label)

    Sets the default label.

    The default label is used if the graphic or feature's attribute value does not match any of the unique values.

    See also defaultLabel.

    void UniqueValueRenderer::setDefaultSymbol(Esri::ArcGISRuntime::Symbol *symbol)

    Sets the default symbol.

    The default symbol is used if the graphic or feature's attribute value does not match any of the unique values.

    See also defaultSymbol.

    void UniqueValueRenderer::setFieldNames(const QStringList &fieldNames)

    Sets the list of fieldNames used in the renderer.

    The names represent attributes of a graphic or feature that the renderer uses to match values against.

    See also fieldNames.

    Esri::ArcGISRuntime::UniqueValueListModel *UniqueValueRenderer::uniqueValues() const

    Returns a collection of unique values for the renderer as a UniqueValueListModel.

    The UniqueValueListModel contains a list model of all the unique values defined in the renderer.

    See also UniqueValueListModel.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.