Change the visibility of sublayers.
Use case
A map image layer may contain many sublayers such as different types of roads in a road network or city, county, and state borders in a US map. The user may only be interested in a subset of these sublayers. Or, perhaps showing all of the sublayers would show too much detail. In these cases, you can hide certain sublayers by changing their visibility.
How to use the sample
Each sublayer has a check box which can be used to toggle the visibility of the sublayer.
How it works
- Create an
ArcGISMapImageLayer
object with the URL to a map image service. - Get the list of sublayers with
mapImageLayer.Sublayers
. - For each layer in the sublayer list, set its visible property to true or false.
Relevant API
- ArcGISMapImageLayer
Tags
layers, sublayers, visibility
Sample Code
<UserControl x:Class="ArcGISRuntime.WPF.Samples.ChangeSublayerVisibility.ChangeSublayerVisibility"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
<Grid>
<esri:MapView x:Name="MyMapView" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<TextBlock Margin="0,0,0,5"
FontWeight="SemiBold"
Text="Select sublayers for display."
TextAlignment="Center"
TextWrapping="Wrap" />
<ListView x:Name="SublayerListView">
<ListView.ItemTemplate>
<DataTemplate DataType="esri:ArcGISSublayer">
<CheckBox Margin="5"
Content="{Binding Name}"
IsChecked="{Binding IsVisible}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
</Border>
</Grid>
</UserControl>