Map image layer sublayer visibility
Change the visibility of sublayers.
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.
Each sublayer has a check box which can be used to toggle the visibility of the sublayer.
- Create an
ArcGISMapImageLayerobject with the URL to a map image service.
- Get the list of sublayers with
- For each layer in the sublayer list, set its visible property to true or false.
layers, sublayers, visibility
<?xml version="1.0" encoding="utf-8" ?> <ContentPage 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" xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime" x:Class="ArcGISRuntime.Samples.ChangeSublayerVisibility.ChangeSublayerVisibility"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Button x:Name="SublayersButton" Text="Sublayer" Clicked="OnSublayersClicked"></Button> <esriUI:MapView x:Name="MyMapView" Grid.Row="1"/> </Grid> </ContentPage>