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
36
37
38
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.SymbolStylesFromWebStyles.SymbolStylesFromWebStyles"
             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>
        <esriUI:MapView x:Name="MyMapView" ViewpointChanged="MapViewExtentChanged" />
        <Button Clicked="LegendButton_Clicked"
                HorizontalOptions="Start"
                Text="Legend"
                VerticalOptions="Start" />
        <ContentView x:Name="LegendPopupView"
                     Margin="5,45"
                     Padding="5"
                     BackgroundColor="White"
                     HeightRequest="350"
                     HorizontalOptions="StartAndExpand"
                     IsVisible="false"
                     VerticalOptions="StartAndExpand"
                     WidthRequest="150">
            <CollectionView x:Name="LegendCollectionView" Margin="5,0">
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="0,5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30" />
                                <ColumnDefinition Width="auto" />
                            </Grid.ColumnDefinitions>
                            <Image Grid.Column="0"
                                   Margin="5,0,5,0"
                                   Source="{Binding ImageSource}" />
                            <Label Grid.Column="1" Text="{Binding Name}" />
                        </Grid>
                    </DataTemplate>
                </CollectionView.ItemTemplate>
            </CollectionView>
        </ContentView>
    </Grid>
</ContentPage>

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