View in MAUI UWP WPF WinUI View on GitHub
import InlineCode from "@esri-dx/starship-doc-components/components/InlineCode.astro";

Apply a renderer to a sublayer.

Image of change sublayer renderer

Use case

A layer showing animal populations contains sublayers for different species. A renderer could be applied which gives each sublayer a different color, so that populations of each species can be compared visually.

How to use the sample

Wait for the map image layer to load. Click the button to apply a unique value renderer to see different population ranges in the counties sub-layer data.

How it works

  1. Create an
    from its URL.
  2. After it is done loading, get its
    with
    .
  3. Cast the sublayer you want to change to the appropriate type:
    .
  4. Create a
    with a collection of
    s for different population ranges.
  5. Set the renderer of the sublayer with
    .

Relevant API

  • ArcGISMapImageLayer
  • ArcGISMapImageSubLayer
  • ClassBreaksRenderer
  • ClassBreaksRenderer.ClassBreak

About the data

This application displays census data from an ArcGIS Server map service. It contains various population statistics, including total population for each county in 2007.

Additional information

The service hosting the layer must support dynamic layers to be able to change the rendering of sublayers.

Tags

class breaks, dynamic layer, dynamic rendering, renderer, sublayer, symbology, visualization

Sample Code

ChangeSublayerRenderer.xaml ChangeSublayerRenderer.xaml ChangeSublayerRenderer.xaml.cs
<UserControl x:Name="_this"
x:Class="ArcGIS.WinUI.Samples.ChangeSublayerRenderer.ChangeSublayerRenderer"
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" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock x:Name="ChangeSublayerRendererInstructionsLabel"
Margin="0,0,0,10"
FontWeight="SemiBold"
Text="Click 'change sublayer renderer' to apply a unique value renderer to the counties sub-layer."
TextWrapping="Wrap" />
<Button x:Name="ChangeSublayerRendererButton"
HorizontalAlignment="Stretch"
Click="ChangeSublayerRendererButton_Click"
Content="Change sublayer renderer" />
</StackPanel>
</Border>
</Grid>
</UserControl>