Read symbols from mobile style

View inAndroidFormsUWPWPFiOSWinUIView on GitHubSample viewer app

Combine multiple symbols from a mobile style file into a single symbol.

Image of read symbols from mobile style

Use case

You may choose to display individual elements of a dataset like a water infrastructure network (such as valves, nodes, or endpoints) with the same basic shape, but wish to modify characteristics of elements according to some technical specifications. Multilayer symbols lets you add or remove components or modify the colors to create advanced symbol styles.

How to use the sample

Select a symbol and a color from each of the category lists to create an emoji. A preview of the symbol is updated as selections are made. The size of the symbol can be set using the slider. Click the map to create a point graphic using the customized emoji symbol, and click "Reset" to clear all graphics from the display.

How it works

  1. On startup, read a mobile style file using SymbolStyle.OpenAsync.
  2. Get a list of all symbols in the style by calling SearchSymbolsAsync with the default search parameters.
  3. Iterate the list of SymbolStyleSearchResult and add symbols to list boxes according to their category. Display a preview of each symbol with CreateSwatchAsync.
  4. When symbol selections change, create a new multilayer symbol by passing the keys for the selected symbols into GetSymbolAsync. Color lock all symbol layers except the base layer and update the current symbol preview image.
  5. Create graphics symbolized with the current symbol when the user taps the map view.

Relevant API

  • MultilayerPointSymbol
  • MultilayerSymbol.CreateSwatchAsync
  • SymbolLayer
  • SymbolStyle
  • SymbolStyle.GetSymbolAsync
  • SymbolStyleSearchParameters

Offline data

Emoji mobile style

About the data

The mobile style file used in this sample was created using ArcGIS Pro, and is hosted on ArcGIS Online. It contains symbol layers that can be combined to create emojis.

Additional information

While each of these symbols can be created from scratch, a more convenient workflow is to author them using ArcGIS Pro and store them in a mobile style file (.stylx). ArcGIS Runtime can read symbols from a mobile style, and you can modify and combine them as needed in your app.

Tags

advanced symbology, mobile style, multilayer, stylx

Sample Code

SymbolsFromMobileStyle.xamlSymbolsFromMobileStyle.xamlSymbolsFromMobileStyle.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<UserControl x:Class="ArcGISRuntime.WPF.Samples.SymbolsFromMobileStyle.SymbolsFromMobileStyle"
             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"
             xmlns:local="clr-namespace:ArcGISRuntime.WPF.Samples.SymbolsFromMobileStyle">
    <UserControl.Resources>
        <local:ColorToSolidBrushConverter x:Key="ColorToBrushConverter" />
    </UserControl.Resources>
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Width="400"
                Height="290"
                Margin="0,20,20,0"
                Padding="0"
                Style="{StaticResource BorderStyle}">
            <Grid Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="140" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                    <RowDefinition Height="40" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <ListBox x:Name="EyeSymbolList"
                         Grid.Row="0"
                         Grid.Column="0"
                         Margin="20"
                         SelectionChanged="SymbolPropertyChanged"
                         SelectionMode="Single">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Image Height="15"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Source="{Binding ImageSrc}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <ListBox x:Name="MouthSymbolList"
                         Grid.Row="0"
                         Grid.Column="1"
                         Margin="20"
                         SelectionChanged="SymbolPropertyChanged"
                         SelectionMode="Single">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Image Height="15"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Source="{Binding ImageSrc}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <ListBox x:Name="HatSymbolList"
                         Grid.Row="0"
                         Grid.Column="2"
                         Margin="20"
                         SelectionChanged="SymbolPropertyChanged"
                         SelectionMode="Single">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Image Height="20"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Source="{Binding ImageSrc}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <Slider x:Name="SizeSlider"
                        Grid.Row="1"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Margin="10,0"
                        LargeChange="5"
                        Maximum="60"
                        Minimum="8"
                        SmallChange="1"
                        Value="20" />
                <Label x:Name="SizeLabel"
                       Grid.Row="1"
                       Grid.Column="2">
                    <Label.Content>
                        <TextBlock>
                            <Run Text="Size:" />
                            <Run Text="{Binding ElementName=SizeSlider, Path=Value, StringFormat={}{0:#}}" />
                        </TextBlock>
                    </Label.Content>
                </Label>
                <ComboBox x:Name="FaceColorComboBox"
                          Grid.Row="2"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Width="150"
                          Height="25"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          HorizontalContentAlignment="Center"
                          SelectionChanged="SymbolPropertyChanged">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <Border Width="150"
                                    Height="25"
                                    Background="{Binding Converter={StaticResource ColorToBrushConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>

                <Image x:Name="SymbolPreviewImage"
                       Grid.Row="2"
                       Grid.RowSpan="2"
                       Grid.Column="2"
                       Width="80"
                       Height="80" />
                <Button x:Name="ClearGraphicsButton"
                        Grid.Row="3"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Width="140"
                        Height="20"
                        Click="ClearGraphicsClick"
                        Content="Clear graphics" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

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