View in MAUI WPF WinUI View on GitHub

Use a symbol to display a geometry on a map.

Screenshot of Style geometry types with symbols sample

Use case

Customize the appearance of a geometry type with a symbol style suitable for the data. For example, a tourism office may use pictures of landmarks as symbols on an online map or app to help prospective visitors orient themselves more easily around a city. A point on the map styled with a circle could represent a drilled borehole location, whereas a cross could represent the location of an old coal mine shaft. A red line with a dashed style could represent a geological fault mapped on a geological map. A polygon with a brown ‘forward-diagonal’ fill style could represent an area of artificial ground mapped on a geological map.

How to use the sample

Tap “Edit Styles” and select a geometry to edit with the picker. Use the controls to change the symbol properties for the geometry.

How it works

  1. Create a PictureMarkerSymbol or SimpleMarkerSymbol to style a Point.
    • For the picture marker symbol, create it using a URL or image and set its height property.
    • For the simple marker symbol, set the Style, Color, and Size properties.
  2. Create a SimpleLineSymbol to style a Polyline.
    • Set the Style, Color, and Size properties.
  3. Create a SimpleFillSymbol to style a Polygon.
    • Set the Style, Color, and Outline properties.
  4. Create Graphics using the geometries and symbols and add them to a GraphicsOverlay.
  5. Add the graphics overlay to a MapView.

Relevant API

  • Geometry
  • Graphic
  • GraphicsOverlay
  • PictureMarkerSymbol
  • SimpleFillSymbol
  • SimpleLineSymbol
  • SimpleMarkerSymbol

Tags

display, fill, graphics, line, marker, overlay, picture, point, symbol, visualization

Sample Code

StyleGeometryTypesWithSymbols.xaml StyleGeometryTypesWithSymbols.xaml StyleGeometryTypesWithSymbols.xaml.cs
<UserControl x:Class="ArcGIS.WinUI.Samples.StyleGeometryTypesWithSymbols.StyleGeometryTypesWithSymbols"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="using:Esri.ArcGISRuntime"
xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Margin" Value="5" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
<Style TargetType="ComboBox">
<Setter Property="Margin" Value="5" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
<Style TargetType="Slider" BasedOn="{StaticResource DefaultSliderStyle}">
<Setter Property="Margin" Value="5" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="TabView">
<Setter Property="Margin" Value="5" />
</Style>
<Style TargetType="TabViewItem">
<Setter Property="IsClosable" Value="False" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="Margin" Value="5" />
</Style>
</UserControl.Resources>
<Grid>
<esriUI:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock HorizontalAlignment="Center"
FontSize="20"
FontWeight="Bold"
Text="Edit Styles" />
<TabView CanDragTabs="False"
CanReorderTabs="False"
IsAddTabButtonVisible="False"
SelectionChanged="GeometryTypeTabControl_SelectionChanged">
<TabViewItem Header="Point">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Style" />
<ComboBox Grid.Column="1"
ItemsSource="{Binding SimpleMarkerSymbolStyles}"
SelectedIndex="0"
SelectionChanged="StyleComboBox_SelectionChanged" />
<Border x:Name="PointColorPreview"
Grid.Row="1"
Background="Purple" />
<Button Grid.Row="1"
Grid.Column="1"
Click="ColorDialogButton_Click"
Content="Open color dialog"
Tag="{x:Bind PointColorPreview}" />
<TextBlock Grid.Row="2">
<Run Text="Size:" />
<Run Text="{Binding ElementName=PointSizeSlider, Path=Value}" />
</TextBlock>
<Slider x:Name="PointSizeSlider"
Grid.Row="2"
Grid.Column="1"
Maximum="15"
Minimum="5"
SmallChange="1"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="12" />
</Grid>
</TabViewItem>
<TabViewItem Header="Polyline">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Text="Style" />
<ComboBox Grid.Column="1"
ItemsSource="{Binding SimpleLineSymbolStyles}"
SelectedIndex="2"
SelectionChanged="StyleComboBox_SelectionChanged" />
<Border x:Name="PolylineColorPreview"
Grid.Row="1"
Background="Red" />
<Button Grid.Row="1"
Grid.Column="1"
Click="ColorDialogButton_Click"
Content="Open color dialog"
Tag="{x:Bind PolylineColorPreview}" />
<TextBlock Grid.Row="2">
<Run Text="Size:" />
<Run Text="{Binding ElementName=PolylineWidthSlider, Path=Value}" />
</TextBlock>
<Slider x:Name="PolylineWidthSlider"
Grid.Row="2"
Grid.Column="1"
Maximum="10"
Minimum="1"
SmallChange="1"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="6" />
</Grid>
</TabViewItem>
<TabViewItem Header="Polygon">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.ColumnSpan="2"
HorizontalAlignment="Center"
FontWeight="Bold"
Text="Fill" />
<TextBlock Grid.Row="1" Text="Style" />
<ComboBox x:Name="PolygonFillStyles"
Grid.Row="1"
Grid.Column="1"
ItemsSource="{Binding SimpleFillSymbolStyles}"
SelectedIndex="3"
SelectionChanged="PolygonFillStyleComboBox_SelectionChanged" />
<Border x:Name="PolygonFillColorPreview"
Grid.Row="2"
Background="Blue" />
<Button Grid.Row="2"
Grid.Column="1"
Click="PolygonFillColorDialogButton_Click"
Content="Open color dialog"
Tag="{x:Bind PolygonFillColorPreview}" />
<TextBlock Grid.Row="3"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
FontWeight="Bold"
Text="Outline" />
<TextBlock Grid.Row="4" Text="Style" />
<ComboBox Grid.Row="4"
Grid.Column="2"
ItemsSource="{Binding SimpleLineSymbolStyles}"
SelectedIndex="5"
SelectionChanged="PolygonOutlineStyleComboBox_SelectionChanged" />
<Border x:Name="PolygonOutlineColorPreview"
Grid.Row="5"
Background="Green" />
<Button Grid.Row="5"
Grid.Column="1"
Click="PolygonOutlineColorDialogButton_Click"
Content="Open color dialog"
Tag="{x:Bind PolygonOutlineColorPreview}" />
<TextBlock Grid.Row="6">
<Run Text="Size:" />
<Run Text="{Binding ElementName=PolygonOutlineWidthSlider, Path=Value}" />
</TextBlock>
<Slider x:Name="PolygonOutlineWidthSlider"
Grid.Row="6"
Grid.Column="1"
Maximum="10"
Minimum="1"
SmallChange="1"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="3" />
</Grid>
</TabViewItem>
</TabView>
</StackPanel>
</Border>
<ContentDialog x:Name="ColorDialog" CloseButtonText="Apply">
<ColorPicker HorizontalAlignment="Center" VerticalAlignment="Center" />
</ContentDialog>
</Grid>
</UserControl>