Map image layer sublayer visibility

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Change the visibility of sublayers.

screenshot

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

  1. Create an ArcGISMapImageLayer object with the URL to a map image service.
  2. Get the list of sublayers with mapImageLayer.Sublayers.
  3. For each layer in the sublayer list, set its visible property to true or false.

Relevant API

  • ArcGISMapImageLayer

Tags

layers, sublayers, visibility

Sample Code

ChangeSublayerVisibility.xamlChangeSublayerVisibility.xamlChangeSublayerVisibility.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.ChangeSublayerVisibility.ChangeSublayerVisibility"
             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>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button x:Name="SublayersButton"
                Clicked="OnSublayersClicked"
                Text="Sublayer" />
        <esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
    </Grid>
</ContentPage>

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