A renderer that displays different symbols based on unique values in the feature attributes. More...
Header: | #include <UniqueValueRenderer.h> |
Since: | Esri::ArcGISRuntime 100.0 |
Inherits: | Esri::ArcGISRuntime::Renderer |
This class was introduced in Esri::ArcGISRuntime 100.0.
Public Functions
UniqueValueRenderer(const QString &defaultLabel, Esri::ArcGISRuntime::Symbol *symbol, const QStringList &fieldNames, const QList<Esri::ArcGISRuntime::UniqueValue *> &uniqueValues, QObject *parent = nullptr) | |
UniqueValueRenderer(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 symbolizes groups of graphics or features that have matching attributes with the same symbol. This is most common with nominal, or string data. Different groups will display with different symbols.
For example, you could use a unique value renderer to symbolize zoning designations: yellow for "Residential", purple for "Industrial", red for "Commercial", and so on. You can also use unique value renderers on numeric fields that are coded values, or on ordinal attributes such as "First", "Second", "Third", and so on.
Typically, graphics and features are rendered based on the unique values of one attribute field. However, up to three fields can be combined to generate a unique value.
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
UniqueValueRenderer::UniqueValueRenderer (const QString &defaultLabel , Esri::ArcGISRuntime::Symbol *symbol, const QStringList &fieldNames , const QList<Esri::ArcGISRuntime::UniqueValue *> &uniqueValues , QObject *parent = nullptr)
Constructor that takes a defaultLabel, a symbol, a list of fieldNames, and a list of uniqueValues, with an optional parent.
UniqueValueRenderer::UniqueValueRenderer (QObject *parent = nullptr)
Default constructor with an optional parent.
[override virtual]
UniqueValueRenderer::~UniqueValueRenderer ()
Destructor.
QString UniqueValueRenderer::defaultLabel () const
Returns the default label.
See also setDefaultLabel.
Esri::ArcGISRuntime::Symbol *UniqueValueRenderer::defaultSymbol () const
Returns the default symbol.
See also setDefaultSymbol.
QStringList UniqueValueRenderer::fieldNames () const
Returns list of field names used in the renderer.
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.