Click or drag to resize

LayerViewState Class

Class to indicate the current state of a layer in a view.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingLayerViewState

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class LayerViewState

The LayerViewState type exposes the following members.

Properties
  NameDescription
Public propertyError
Gets the layer view error from the layer view state.
Public propertyCode exampleStatus
Gets the LayerViewStatus from the layer view state.
Top
Examples

WPF

Example Name: DisplayLayerViewState

Determine if a layer is currently being viewed.

Code example screen shot.

C#
// Copyright 2016 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific 
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using System;

namespace ArcGISRuntime.WPF.Samples.DisplayLayerViewState
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Display layer view state",
        category: "MapView",
        description: "Determine if a layer is currently being viewed.",
        instructions: "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.",
        tags: new[] { "layer", "map", "status", "view" })]
    public partial class DisplayLayerViewState
    {

        public DisplayLayerViewState()
        {
            InitializeComponent();

            // Create the UI, setup the control references and execute initialization 
            Initialize();
        }

        private void Initialize()
        {
            // Create new Map
            Map myMap = new Map();

            // Create the uri for the tiled layer
            Uri tiledLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer");

            // Create a tiled layer using url
            ArcGISTiledLayer tiledLayer = new ArcGISTiledLayer(tiledLayerUri)
            {
                Name = "Tiled Layer"
            };

            // Add the tiled layer to map
            myMap.OperationalLayers.Add(tiledLayer);

            // Create the uri for the ArcGISMapImage layer
            Uri imageLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer");

            // Create ArcGISMapImage layer using a url
            ArcGISMapImageLayer imageLayer = new ArcGISMapImageLayer(imageLayerUri)
            {
                Name = "Image Layer",

                // Set the visible scale range for the image layer
                MinScale = 40000000,
                MaxScale = 2000000
            };

            // Add the image layer to map
            myMap.OperationalLayers.Add(imageLayer);

            // Create Uri for feature layer
            Uri featureLayerUri = new Uri(
                "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Recreation/FeatureServer/0");

            // Create a feature layer using url
            FeatureLayer myFeatureLayer = new FeatureLayer(featureLayerUri)
            {
                Name = "Feature Layer"
            };

            // Add the feature layer to map
            myMap.OperationalLayers.Add(myFeatureLayer);

            // Create a map point the map should zoom to
            MapPoint mapPoint = new MapPoint(-11000000, 4500000, SpatialReferences.WebMercator);

            // Set the initial viewpoint for map
            myMap.InitialViewpoint = new Viewpoint(mapPoint, 50000000);

            // Event for layer view state changed
            MyMapView.LayerViewStateChanged += OnLayerViewStateChanged;

            // Provide used Map to the MapView
            MyMapView.Map = myMap;
        }

        private void OnLayerViewStateChanged(object sender, LayerViewStateChangedEventArgs e)
        {
            // For each execution of the MapView.LayerViewStateChanged Event, get the name of
            // the layer and its LayerViewState.Status
            string lName = e.Layer.Name;
            string lViewStatus = e.LayerViewState.Status.ToString();

            // Display the layer view status in the appropriate Label control
            switch (lName)
            {
                case "Tiled Layer":
                    TiledLayerStatusLabel.Text = lViewStatus;
                    break;
                case "Image Layer":
                    ImageLayerStatusLabel.Text = lViewStatus;
                    break;
                case "Feature Layer":
                    FeatureLayerStatusLabel.Text = lViewStatus;
                    break;
                default:
                    break;
            }
        }
    }
}
XAML
<UserControl x:Class="ArcGISRuntime.WPF.Samples.DisplayLayerViewState.DisplayLayerViewState"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.Resources>
                    <Style TargetType="TextBlock">
                        <Setter Property="Margin" Value="5,5,0,0" />
                    </Style>
                </Grid.Resources>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="Layer display status"
                           Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"
                           FontWeight="Bold" TextAlignment="Center" />
                <!-- Field labels -->
                <TextBlock Text="Tiled layer:"
                           TextAlignment="Right"
                           Grid.Row="1" Grid.Column="0" />
                <TextBlock Text="Image layer:"
                           TextAlignment="Right"
                           Grid.Row="2" Grid.Column="0" />
                <TextBlock Text="Feature layer:"
                           TextAlignment="Right"
                           Grid.Row="3" Grid.Column="0" />
                <!-- Status labels -->
                <TextBlock x:Name="TiledLayerStatusLabel"
                           FontWeight="SemiBold"
                           Grid.Row="1" Grid.Column="1" />
                <TextBlock x:Name="ImageLayerStatusLabel"
                           FontWeight="SemiBold"
                           Grid.Row="2" Grid.Column="1" />
                <TextBlock x:Name="FeatureLayerStatusLabel"
                           FontWeight="SemiBold"
                           Grid.Row="3" Grid.Column="1" />
            </Grid>
        </Border>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
DisplayLayerViewStateDetermine if a layer is currently being viewed.