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.WPF.Samples.StyleGeometryTypesWithSymbols.StyleGeometryTypesWithSymbols"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:ArcGIS.WPF.Viewer.Converters"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<UserControl.Resources>
<Style TargetType="Button" BasedOn="{StaticResource CalciteButtonBaseStyle}">
<Setter Property="Margin" Value="5" />
</Style>
<Style TargetType="ComboBox" BasedOn="{StaticResource CalciteComboBoxStyle}">
<Setter Property="Margin" Value="5" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
</Style>
<Style TargetType="Label">
<Setter Property="Margin" Value="5" />
</Style>
<Style TargetType="Slider" BasedOn="{StaticResource CalciteSliderStyle}">
<Setter Property="Margin" Value="5" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style TargetType="TabControl" BasedOn="{StaticResource CalciteTabControlStyle}">
<Setter Property="Margin" Value="5" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="Margin" Value="5" />
</Style>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="Margin" Value="5" />
</Style>
</UserControl.Resources>
<Grid>
<esri:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<Label HorizontalAlignment="Center"
Content="Edit Styles"
FontSize="20"
FontWeight="Bold" />
<TabControl SelectionChanged="GeometryTypeTabControl_SelectionChanged">
<TabItem Header="Point">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="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:Reference 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"
IsSnapToTickEnabled="True"
Maximum="15"
Minimum="5"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="12" />
</Grid>
</TabItem>
<TabItem Header="Polyline">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Content="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:Reference 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"
IsSnapToTickEnabled="True"
Maximum="10"
Minimum="1"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="6" />
</Grid>
</TabItem>
<TabItem Header="Polygon">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Grid.ColumnSpan="2"
HorizontalAlignment="Center"
Content="Fill"
FontWeight="Bold" />
<Label Grid.Row="1" Content="Style" />
<ComboBox 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:Reference PolygonFillColorPreview}" />
<Label Grid.Row="3"
Grid.ColumnSpan="2"
HorizontalAlignment="Center"
Content="Outline"
FontWeight="Bold" />
<Label Grid.Row="4" Content="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:Reference 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"
IsSnapToTickEnabled="True"
Maximum="10"
Minimum="1"
TickFrequency="1"
ValueChanged="SizeSlider_ValueChanged"
Value="3" />
</Grid>
</TabItem>
</TabControl>
</StackPanel>
</Border>
</Grid>
</UserControl>