Display layer view state

View inMAUIUWPWPFWinUIView on GitHub

Determine if a layer is currently being viewed.

Image of display layer view state

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

  1. Create an Map with some operational layers.
  2. Set the map on a MapView.
  3. 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

DisplayLayerViewState.xamlDisplayLayerViewState.xamlDisplayLayerViewState.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<UserControl
    x:Class="ArcGIS.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>

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