Display layer view state

View inWPFUWPFormsiOSAndroid
View 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.xaml.cs
                     
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?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.DisplayLayerViewState.DisplayLayerViewState">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="150" />
    </Grid.RowDefinitions>
    <esriUI:MapView x:Name="MyMapView" Grid.Row="0"/>
    <ListView x:Name="layerStatusListView" Grid.Row="1">
      <ListView.ItemTemplate>
        <DataTemplate>
          <TextCell Text="{Binding Message}"/>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </Grid>
</ContentPage>

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