Determine if a layer is currently being viewed.
Use case
The view state includes information on the loading state of layers and whether layers are visible at a given scale. For example, you might change how a layer is displayed in a layer list to communicate whether it is being viewed in the map.
How to use the sample
Pan and zoom around in the map. Each layer's view status is displayed. Notice that some layers configured with a min and max scale change to "OutOfScale" at certain scales.
How it works
- Create an
Map
with some operational layers. - Set the map on a
MapView
. - Add an event handler for the
LayerViewStateChanged
event in the map view.
Relevant API
- LayerViewStateChanged
- LayerViewStateChangedEventArgs
- Map
- MapView
About the data
The map shows a tiled layer of world time zones, a map image layer of the census, and a feature layer of recreation services.
Tags
layer, map, status, view
Sample Code
<UserControl
x:Class="ArcGISRuntime.UWP.Samples.DisplayLayerViewState.DisplayLayerViewState"
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 Background="White" BorderBrush="Black" BorderThickness="1"
HorizontalAlignment="Right" VerticalAlignment="Top"
Margin="30" Padding="20" Width="375">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="Tiled layer:"
Grid.Row="0" Grid.Column="0"
Margin="0,5,0,0"
HorizontalAlignment="Right" />
<TextBlock x:Name="TiledLayerStatus"
Grid.Row="0" Grid.Column="1"
Margin="5,5,0,0"
FontWeight="SemiBold" />
<TextBlock Text="Image layer:"
Grid.Row="1" Grid.Column="0"
Margin="0,5,0,0"
HorizontalAlignment="Right" />
<TextBlock x:Name="ImageLayerStatus"
Grid.Row="1" Grid.Column="1"
Margin="5,5,0,0"
FontWeight="SemiBold" />
<TextBlock Text="Feature layer:"
Grid.Row="2" Grid.Column="0"
Margin="0,5,0,0"
HorizontalAlignment="Right" />
<TextBlock x:Name="FeatureLayerStatus"
Grid.Row="2" Grid.Column="1"
Margin="5,5,0,0"
FontWeight="SemiBold" />
</Grid>
</Border>
</Grid>
</UserControl>