Custom dictionary style

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Use a custom dictionary created from a web style or style file (.stylx) to symbolize features using a variety of attribute values.

Image of custom dictionary style

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

Use the radio buttons to toggle between the dictionary symbols from the web style and style file. Pan and zoom around the map to see the symbology from the chosen dictionary symbol style. The web style and style file are slightly different to each other to give a visual indication of the switch between the two.

How it works

  1. Create a new FeatureLayer and append it to the Map's operational layers.
  2. Use DictionarySymbolStyle.CreateFromFileAsync() to create a DictionarySymbolStyle from a .stylx file.
  3. Create a DictionarySymbolStyle with a PortalItem.
  4. Create and apply the desired DictionaryRenderer to the FeatureLayer for each DictionarySymbolStyle by selecting the appropriate radio button.

Relevant API

  • DictionaryRenderer
  • DictionarySymbolStyle
  • DictionarySymbolStyleConfiguration
  • PortalItem

Offline data

This sample downloads the following items from ArcGIS Online automatically:

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 created from a stylx file and a web style, available as an items 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

For information about creating your own custom dictionary style, see the open source dictionary renderer toolkit on GitHub.

Tags

ArcGIS Online, dictionary, military, renderer, style, stylx, unique value, visualization, web style

Sample Code

CustomDictionaryStyle.xamlCustomDictionaryStyle.xamlCustomDictionaryStyle.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.CustomDictionaryStyle.CustomDictionaryStyle"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="370" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <esriUI:MapView x:Name="MyMapView"
                        Grid.Row="0"
                        Grid.Column="0"
                        Grid.ColumnSpan="3" />
        <Label Grid.Row="1"
               Grid.Column="1"
               Padding="0,0,0,5"
               Text="Select Dictionary Symbol Style Source" />
        <RadioButton x:Name="LocalStyleButton"
                     Grid.Row="2"
                     Grid.Column="1"
                     CheckedChanged="LocalStyleButtonClicked"
                     Content="Local .stylx file" />
        <RadioButton x:Name="WebStyleButton"
                     Grid.Row="3"
                     Grid.Column="1"
                     CheckedChanged="WebStyleButtonClicked"
                     Content="Web style" />
    </Grid>
</ContentPage>

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