Click or drag to resize

DictionarySymbolStyle Class

A dictionary symbol style object containing symbol primitives and rules for generating symbols from attribute values.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.SymbologySymbolStyle
    Esri.ArcGISRuntime.SymbologyDictionarySymbolStyle

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public class DictionarySymbolStyle : SymbolStyle

The DictionarySymbolStyle type exposes the following members.

Properties
  NameDescription
Public propertyConfigurationProperties Obsolete.
Gets or sets the dictionary of configuration settings and values used by the style. These settings are specific to the rule engine used by the DictionarySymbolStyle.
Public propertyConfigurations
Gets the list of configuration settings for the custom dictionary style.
Public propertyCredential
Gets or sets the Credential used to access a remote style.
(Inherited from SymbolStyle.)
Public propertyDictionaryName
Gets the name of the custom Arcade-based dictionary style. For older version style files, this is an empty string.
Public propertyPortal
Gets the Portal that hosts the web style identified with Portal. This will be null if the style was identified with a PortalItem or Uri or a local .stylx file on disk.
(Inherited from SymbolStyle.)
Public propertyPortalItem
Gets the PortalItem representing the web style.
(Inherited from SymbolStyle.)
Public propertySpecificationType Obsolete.
Gets the name of the dictionary (.stylx file), such as "mil2525d".
Public propertyStyleLocation
Gets the file location of the .stylx file on disk. This will be empty if the style was hosted on a portal (also referred to as a web style).
(Inherited from SymbolStyle.)
Public propertyStyleName
Gets the name of the web style. This will be empty if the web style was identified with a Uri or a PortalItem or a local .stylx file on disk.
(Inherited from SymbolStyle.)
Public propertySymbologyFieldNames
Gets the string list of attributes used to construct a symbol from the dictionary style.
Public propertyTextFieldNames
Gets the string list of attributes used to obtain text values for display with a symbol from a dictionary style.
Public propertyUri
Gets the Uri of the web symbol style item. This will be null if the style was identified with a PortalItem, style name or a local .stylx file on disk.
(Inherited from SymbolStyle.)
Top
Methods
  NameDescription
Public methodStatic memberCode exampleCreateFromFileAsync
Creates a new a DictionarySymbolStyle from the style file at the provided location.
Public methodCode exampleGetDefaultSearchParametersAsync
Returns a Style Symbol Search Parameters object providing the default search parameters from the database.
(Inherited from SymbolStyle.)
Public methodGetSymbolAsync(IDictionaryString, Object)
Asynchronously returns a symbol based on the provided attributes.
Public methodCode exampleGetSymbolAsync(IEnumerableString)
Asynchronously returns a symbol based on the provided list of keys.
(Inherited from SymbolStyle.)
Public methodStatic memberOpenAsync(Uri)
Opens a new DictionarySymbolStyle from a dictionary web style item Uri.
Public methodStatic memberOpenAsync(PortalItem)
Opens a DictionarySymbolStyle from a portal item. The portal item must be a dictionary web style.
Public methodStatic memberOpenAsync(String, String) Obsolete.
Opens a DictionarySymbolStyle using the style file identified by the specification type or style location.
Public methodCode exampleSearchSymbolsAsync
Returns a collection of SymbolStyleSearchResult objects.
(Inherited from SymbolStyle.)
Top
Remarks

A DictionarySymbolStyle is created with either from a style file on disk (an SQLite database with a .stylx extension, created with ArcGIS Pro) or from a dictionary style file hosted on ArcGIS Online or an ArcGIS Enterprise portal (also referred to as a dictionary web style).

A DictionarySymbolStyle must contain a set of symbol primitives and a rule engine that parses input fields. The DictionarySymbolStyle assembles new symbols based on the input attribute values. DictionarySymbolStyle is often used to render symbols from a military specification (such as MIL-STD 2525D or APP-6B) but can also be used with a custom style.

A DictionarySymbolStyle is used in conjunction with a DictionaryRenderer to symbolize geoelements in a FeatureLayer or GraphicsOverlay.

Examples

WPF

Example Name: DictionaryRendererGraphicsOverlay

This sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Xml.Linq;
using PointCollection = Esri.ArcGISRuntime.Geometry.PointCollection;

namespace ArcGISRuntime.WPF.Samples.DictionaryRendererGraphicsOverlay
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Graphics overlay (dictionary renderer)",
        category: "GraphicsOverlay",
        description: "This sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.",
        instructions: "Pan and zoom to explore military symbols on the map.",
        tags: new[] { "defense", "military", "situational awareness", "tactical", "visualization" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("c78b149a1d52414682c86a5feeb13d30", "1e4ea99af4b440c092e7959cf3957bfa")]
    public partial class DictionaryRendererGraphicsOverlay
    {
        // Hold a reference to the graphics overlay for easy access.
        private GraphicsOverlay _tacticalMessageOverlay;

        public DictionaryRendererGraphicsOverlay()
        {
            InitializeComponent();
            Initialize();
        }

        private async void Initialize()
        {
            try
            {
                MyMapView.Map = new Map(BasemapStyle.ArcGISTopographic);

                // Create an overlay for visualizing tactical messages and add it to the map.
                _tacticalMessageOverlay = new GraphicsOverlay();
                MyMapView.GraphicsOverlays.Add(_tacticalMessageOverlay);

                // Prevent graphics from showing up when zoomed too far out.
                _tacticalMessageOverlay.MinScale = 1000000;

                // Create a symbol dictionary style following the mil2525d spec.
                string symbolFilePath = DataManager.GetDataFolder("c78b149a1d52414682c86a5feeb13d30", "mil2525d.stylx");
                DictionarySymbolStyle mil2525DStyle = await DictionarySymbolStyle.CreateFromFileAsync(symbolFilePath);

                // Use the dictionary symbol style to render graphics in the overlay.
                _tacticalMessageOverlay.Renderer = new DictionaryRenderer(mil2525DStyle);

                // Load the military messages and render them.
                LoadMilitaryMessages();

                // Get the extent of the graphics.
                Envelope graphicExtent = GeometryEngine.CombineExtents(_tacticalMessageOverlay.Graphics.Select(graphic => graphic.Geometry));

                // Zoom to the extent of the graphics.
                await MyMapView.SetViewpointGeometryAsync(graphicExtent, 10);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MessageBox.Show(e.ToString());
            }
        }

        private void LoadMilitaryMessages()
        {
            // Get the path to the messages file.
            string militaryMessagePath = DataManager.GetDataFolder("1e4ea99af4b440c092e7959cf3957bfa", "Mil2525DMessages.xml");

            // Load the XML document.
            XElement xmlRoot = XElement.Load(militaryMessagePath);

            // Get all of the messages.
            IEnumerable<XElement> messages = xmlRoot.Descendants("message");

            // Add a graphic for each message.
            foreach (var message in messages)
            {
                Graphic messageGraphic = GraphicFromAttributes(message.Descendants().ToList());
                _tacticalMessageOverlay.Graphics.Add(messageGraphic);
            }
        }

        private Graphic GraphicFromAttributes(List<XElement> graphicAttributes)
        {
            // Get the geometry and the spatial reference from the message elements.
            XElement geometryAttribute = graphicAttributes.First(attr => attr.Name == "_control_points");
            XElement spatialReferenceAttr = graphicAttributes.First(attr => attr.Name == "_wkid");

            // Split the geometry field into a list of points.
            Array pointStrings = geometryAttribute.Value.Split(';');

            // Create a point collection in the correct spatial reference.
            int wkid = Convert.ToInt32(spatialReferenceAttr.Value);
            SpatialReference pointSR = SpatialReference.Create(wkid);
            PointCollection graphicPoints = new PointCollection(pointSR);

            // Add a point for each point in the list.
            foreach (string pointString in pointStrings)
            {
                var coords = pointString.Split(',');
                graphicPoints.Add(Convert.ToDouble(coords[0]), Convert.ToDouble(coords[1]));
            }

            // Create a multipoint from the point collection.
            Multipoint graphicMultipoint = new Multipoint(graphicPoints);

            // Create the graphic from the multipoint.
            Graphic messageGraphic = new Graphic(graphicMultipoint);

            // Add all of the message's attributes to the graphic (some of these are used for rendering).
            foreach (XElement attr in graphicAttributes)
            {
                messageGraphic.Attributes[attr.Name.ToString()] = attr.Value;
            }

            return messageGraphic;
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.DictionaryRendererGraphicsOverlay.DictionaryRendererGraphicsOverlay"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView"/>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
CustomDictionaryStyleUse a custom dictionary style (.stylx) to symbolize features using a variety of attribute values.
DictionaryRendererGraphicsOverlayThis sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.
FeatureLayerDictionaryRendererConvert features into graphics to show them with mil2525d symbols.