Display layer view state
Determine if a layer is currently being viewed.
The view status includes information on the loading state of layers and whether layers are visible at a given scale. You might change how a layer is displayed in a layer list to communicate whether it is being viewed in the map. For example, you could show a loading spinner next to its name when the view status is
Loading, grey out the name when
OutOfScale, show the name normally when
Active, or with a warning or error icon when the status is
How to use the sample
Tap the Load layer button to add a feature layer to the map. The current view status of the layer will display on the map. Zoom in and out of the map and note the layer disappears when the map is scaled outside of its min and max scale range. Control the layer's visibility with the switch. If you disconnect your device from the network and pan around the map, a warning will display. Reconnect to the network to remove the warning. The layer's current view status will update accordingly as you carry out these actions.
How it works
- Create a
Mapwith an operational layer.
- Set the map on a
- Listen to
LayerViewStateChangedfrom the map view.
- Get the
Layerfor the event with
event.Layerand the current view status with
About the data
The Satellite (MODIS) Thermal Hotspots and Fire Activity layer presents detectable thermal activity from MODIS satellites for the last 48 hours. MODIS Global Fires is a product of NASA’s Earth Observing System Data and Information System (EOSDIS), part of NASA's Earth Science Data. EOSDIS integrates remote sensing and GIS technologies to deliver global MODIS hotspot/fire locations to natural resource managers and other stakeholders around the World.
The following are members of the
Active: The layer in the view is active.
NotVisible: The layer in the view is not visible.
OutOfScale: The layer in the view is out of scale. A status of
OutOfScaleindicates that the view is zoomed outside of the scale range of the layer. If the view is zoomed too far in (e.g. to a street level), it is beyond the max scale defined for the layer. If the view has zoomed too far out (e.g. to global scale), it is beyond the min scale defined for the layer.
Loading: The layer in the view is loading. Once loading has completed, the layer will be available for display in the view. If there was a problem loading the layer, the status will be set to ERROR.
Error: The layer in the view has an unrecoverable error. When the status is
Error, the layer cannot be rendered in the view. For example, it may have failed to load, be an unsupported layer type, or contain invalid data.
Warning: The layer in the view has a non-breaking problem with its display, such as incomplete information (eg. by requesting more features than the max feature count of a service) or a network request failure.
layer, load, map, status, view, visibility
<UserControl x:Class="ArcGIS.WinUI.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 Width="375" Margin="30" Padding="20" HorizontalAlignment="Right" VerticalAlignment="Top" Background="White" BorderBrush="Black" BorderThickness="1"> <StackPanel> <TextBlock Margin="5" Text="Zoom in and out to observe changes in layer status." /> <Button x:Name="LoadButton" Margin="5" Click="LoadButton_Click" Content="Load layer" /> <CheckBox Name="VisibilityCheckBox" Margin="5" Checked="CheckBox_Checked" Content="Visible" IsChecked="True" Unchecked="CheckBox_Checked" /> <StackPanel Orientation="Horizontal"> <TextBlock Margin="5" FontWeight="Bold" Text="Layer display status: " TextAlignment="Center" /> <TextBlock x:Name="LayerStatusLabel" Margin="5" FontWeight="SemiBold" /> </StackPanel> </StackPanel> </Border> </Grid> </UserControl>