Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Runtime SDK for Qt

Custom dictionary style

Sample Viewer View Sample on GitHub

Use a custom dictionary style (.stylx) to symbolize features using a variety of attribute values.

Use case

When symbolizing geoelements in your map, you may need to convey several pieces of information with a single symbol. You could try to symbolize such data using a unique value renderer, but as the number of fields and values increases, that approach becomes impractical. With a dictionary renderer you can build each symbol on-the-fly, driven by one or more attribute values, and handle a nearly infinite number of unique combinations.

How to use the sample

Pan and zoom the map to see the symbology from the custom dictionary style.

How it works

  1. Create a new DictionarySymbolStyle by passing in the path to the custom style file (.stylx).
  2. Create a new DictionaryRenderer, providing the dictionary symbol style.
  3. Apply the dictionary renderer to a feature layer.

Relevant API

  • DictionaryRenderer
  • DictionarySymbolStyle

About the data

The data used in this sample is from a feature layer showing a subset of restaurants in Redlands, CA hosted as a feature service with attributes for rating, style, health score, and open hours. The feature layer is symbolized using a dictionary renderer that displays a single symbol for all of these variables. The renderer uses symbols from a custom restaurant dictionary style, available as an item from ArcGIS Online, to show unique symbols based on several feature attributes. The symbols it contains were created using ArcGIS Pro. The logic used to apply the symbols comes from an Arcade script embedded in the stylx file (which is a SQLite database), along with a JSON string that defines expected attribute names and configuration properties.

Additional information

To learn more about how styles in dictionary renderers work, visit Display symbols from a style with a dictionary renderer. For information about creating your own custom dictionary style, see the open source dictionary-renderer-toolkit.

Tags

dictionary, military, renderer, style, stylx, unique value, visualization

Sample Code

import QtQuick 2.6
import Esri.ArcGISRuntime 100.9
import Esri.ArcGISExtras 1.1

Rectangle {
    id: rootRectangle
    clip: true
    width: 800
    height: 600

    readonly property string dataPath: System.userHomePath + "/ArcGIS/Runtime/Data"

    MapView {
        id: mapView
        anchors.fill: parent

        Map {
            // Set basemap
            BasemapStreetsVector{}

            // Set an initial viewpoint
            ViewpointCenter {
                Point {
                    x: -1.304630524635E7
                    y: 4036698.1412000023
                    SpatialReference { wkid: 3857 }
                }
                targetScale: 5000
            }

            // Add a Feature Layer to the Map
            FeatureLayer {
                ServiceFeatureTable {
                    url: "https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/Redlands_Restaurants/FeatureServer/0"
                }

                // Set a Dictionary Renderer on the Feature Layer
                DictionaryRenderer {
                    id: dictionaryRenderer
                    dictionarySymbolStyle: Factory.DictionarySymbolStyle.createFromFile(dataPath + "/styles/arcade_style/Restaurant.stylx")
                }
            }
        }
    }
}