Create symbol styles from web styles

View inFormsWPFWinUIView on GitHub

Create symbol styles from a style file hosted on a portal.

Image of create symbol styles from web styles

Use case

Style files hosted on an ArcGIS Online or Enterprise portal are known as web styles. They can be used to style symbols on a feature layer or graphic overlay. Since styles are published from ArcGIS Pro, you can author and design your own beautiful multilayer vector symbols. These vector symbols look good at any resolution and scale well. Runtime users can now access these styles from their native application, and make use of the vector symbols within them to enhance features and graphics in the map.

How to use the sample

The sample displays a map with a set of symbols that represent the categories of the features within the dataset. Pan and zoom on the map and view the legend to explore the appearance and names of the different symbols from the selected symbol style.

How it works

  1. Create a FeatureLayer and add it to the map.
  2. Create a UniqueValueRenderer and set it to the feature layer.
  3. Create a SymbolStyle from a portal by passing in the web style name and portal item.
  4. Search for symbols in the symbol style by name using symbolStyle.GetSymbolAsync(new List<string>() { symbolName }).
  5. Create a Symbol from the search result.
  6. Create UniqueValue objects for each symbol with defined values to map the symbol to features on the feature layer.
  7. Add each UniqueValue to the UniqueValueRenderer.

Relevant API

  • FeatureLayer
  • Symbol
  • SymbolStyle
  • UniqueValue
  • UniqueValueRenderer

About the data

The sample uses the 'Esri2DPointSymbolsStyle' Web Style.

The map shows features from the LA County Points of Interest service hosted on ArcGIS Online.

Additional information

2D web styles, dictionary web styles, and 3D web styles can all be hosted on an ArcGIS Online or Enterprise portal.

Tags

renderer, symbol, symbology, web style

Sample Code

SymbolStylesFromWebStyles.xamlSymbolStylesFromWebStyles.xamlSymbolStylesFromWebStyles.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
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.SymbolStylesFromWebStyles.SymbolStylesFromWebStyles"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" ViewpointChanged="MapViewExtentChanged" />
        <StackPanel Width="170"
                    Height="440"
                    Margin="5"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    Background="White">
            <TextBlock Margin="5,5,0,0"
                       FontSize="16"
                       FontWeight="Bold"
                       Text="Legend" />
            <ItemsControl x:Name="LegendItemsControl" Margin="10">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="25" />
                                <ColumnDefinition Width="auto" />
                            </Grid.ColumnDefinitions>
                            <Image Grid.Column="0"
                                   Margin="0,0,3,0"
                                   Source="{Binding ImageSource}" />
                            <TextBlock Grid.Column="1" Text="{Binding Name}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
    </Grid>
</UserControl>

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