Click or drag to resize

LayerCollection Class

A collection of layers
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntimeRuntimeCollectionLayer
    Esri.ArcGISRuntimeRuntimeObservableCollectionLayer
      Esri.ArcGISRuntime.MappingLayerCollection

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public class LayerCollection : RuntimeObservableCollection<Layer>

The LayerCollection type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleLayerCollection
Initializes a new instance of the LayerCollection class.
Top
Properties
Methods
  NameDescription
Public methodCode exampleAdd
Adds an item to the collection.
(Inherited from RuntimeCollectionT.)
Public methodAddRange (Inherited from RuntimeObservableCollectionT.)
Protected methodBlockReentrancy
Disallow reentrant attempts to change this collection. E.g. a event handler of the CollectionChanged event is not allowed to make changes to this collection.
(Inherited from RuntimeObservableCollectionT.)
Protected methodCheckReentrancy
Check and assert for reentrant attempts to change this collection.
(Inherited from RuntimeObservableCollectionT.)
Public methodCode exampleClear
Removes all items from the collection
(Inherited from RuntimeCollectionT.)
Protected methodClearItems
Called by base class Collection<T> when the list is being cleared; raises a CollectionChanged event to any listeners.
(Inherited from RuntimeObservableCollectionT.)
Public methodCode exampleContains
Determines whether the collection contains a specific value.
(Inherited from RuntimeCollectionT.)
Public methodCopyTo
Copies the elements of the collection to an Array, starting at a particular Array index.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleGetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleIndexOf
Determines the index of a specific item in the collection.
(Inherited from RuntimeCollectionT.)
Public methodCode exampleInsert
Inserts an item to the collection at the specified index.
(Inherited from RuntimeCollectionT.)
Protected methodInsertItem
Called by base class Collection<T> when an item is added to list; raises a CollectionChanged event to any listeners.
(Inherited from RuntimeObservableCollectionT.)
Public methodMove
Moves the item at the specified index to a new location in the collection.
(Inherited from RuntimeCollectionT.)
Protected methodMoveItem
Called by base class ObservableCollection<T> when an item is to be moved within the list; raises a CollectionChanged event to any listeners.
(Inherited from RuntimeObservableCollectionT.)
Protected methodOnCollectionChanged
Raises the CollectionChanged event with the provided arguments.
(Inherited from RuntimeObservableCollectionT.)
Protected methodOnPropertyChanged
Raises a PropertyChanged event (per INotifyPropertyChanged).
(Inherited from RuntimeObservableCollectionT.)
Public methodCode exampleRemove
Removes the first occurrence of a specific object from the collection
(Inherited from RuntimeCollectionT.)
Public methodCode exampleRemoveAt
Removes the item at the specified index.
(Inherited from RuntimeCollectionT.)
Protected methodRemoveItem
Called by base class Collection<T> when an item is removed from list; raises a CollectionChanged event to any listeners.
(Inherited from RuntimeObservableCollectionT.)
Protected methodSetItem
Called by base class Collection<T> when an item is set in list; raises a CollectionChanged event to any listeners.
(Inherited from RuntimeObservableCollectionT.)
Top
Events
Examples

Android

Example Name: RasterLayerGeoPackage

Open a GeoPackage, obtain a raster from the package, and display the table as a `RasterLayer`.

Code example screen shot.

C#
// Copyright 2017 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 System;
using System.Linq;
using Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Rasters;

namespace ArcGISRuntime.Samples.RasterLayerGeoPackage
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("68ec42517cdd439e81b036210483e8e7")]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (GeoPackage)",
        "Data",
        "This sample demonstrates how to open a GeoPackage and show a GeoPackage raster in a raster layer.",
        "The GeoPackage will be downloaded from an ArcGIS Online portal automatically.")]
    public class RasterLayerGeoPackage : Activity
    {
        private MapView _myMapView;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Raster layer (GeoPackage)";

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

        private async void Initialize()
        {
            // Create a new map
            _myMapView.Map = new Map(Basemap.CreateLightGrayCanvas());

            // Get the full path
            string geoPackagePath = GetGeoPackagePath();

            try
            {
                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null) { return; }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                _myMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        private static string GetGeoPackagePath()
        {
            return DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add a map view to the layout
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

            // Show the layout in the app
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

Example Name: RasterLayerGeoPackage

Open a `GeoPackage`, obtain a raster from the package, and display the table as a `RasterLayer`.

Code example screen shot.

C#
// Copyright 2017 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 System;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Rasters;
using System.Linq;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.RasterLayerGeoPackage
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (GeoPackage)",
        "Data",
        "This sample demonstrates how to open a GeoPackage and show a GeoPackage raster in a raster layer.",
        "The GeoPackage will be downloaded from an ArcGIS Online portal automatically.")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("68ec42517cdd439e81b036210483e8e7")]
    public partial class RasterLayerGeoPackage : ContentPage
    {
        public RasterLayerGeoPackage()
        {
            InitializeComponent();

            // Read data from the GeoPackage
            Initialize();
        }

        private async void Initialize()
        {
            // Create a new map
            MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas());

            // Get the full path
            string geoPackagePath = GetGeoPackagePath();

            try
            {
                // Open the GeoPackage
                GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

                // Read the raster images and get the first one
                Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

                // Make sure an image was found in the package
                if (gpkgRaster == null) { return; }

                // Create a layer to show the raster
                RasterLayer newLayer = new RasterLayer(gpkgRaster);
                await newLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent));

                // Add the image as a raster layer to the map (with default symbology)
                MyMapView.Map.OperationalLayers.Add(newLayer);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }

        private static string GetGeoPackagePath()

        {
            return DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg");
        }
    }
}
XAML
<?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.RasterLayerGeoPackage.RasterLayerGeoPackage">
    <esriUI:MapView x:Name="MyMapView"/>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddAnIntegratedMeshLayerView an integrated mesh layer from a scene service.
AddEncExchangeSetDisplay nautical charts per the ENC specification.
AddFeaturesAdd features to a feature layer.
AddPointSceneLayerView a point scene layer from a scene service.
AnalyzeHotspotsUse a geoprocessing service and a set of features to identify statistically significant hot spots and cold spots.
ArcGISMapImageLayerUrlAdd an ArcGIS Map Image Layer from a URL to a map.
ArcGISTiledLayerUrlLoad an ArcGIS tiled layer from a URL.
AuthorMapCreate and save a map as an ArcGIS `PortalItem` (i.e. web map).
BrowseWfsLayersBrowse a WFS service for layers.
BufferListGenerate multiple individual buffers or a single unioned buffer around multiple points.
ChangeEncDisplaySettingsConfigure the display of ENC content.
ChangeFeatureLayerRendererChange the appearance of a feature layer with a renderer.
ChangeStretchRendererUse a stretch renderer to enhance the visual contrast of raster data for analysis.
ChangeSublayerRendererApply a renderer to a sublayer.
ChangeSublayerVisibilityChange the visibility of sublayers.
ChangeTimeExtentThis sample demonstrates how to filter data in layers by applying a time extent to a MapView.
ChangeViewpointSet the map view to a new viewpoint.
ClosestFacilityStaticFind routes from several locations to the respective closest facility.
ControlAnnotationSublayerVisibilityUse annotation sublayers to gain finer control of annotation layer subtypes.
CreateAndSaveKmlFileConstruct a KML document and save it as a KMZ file.
CreateFeatureCollectionLayerCreate a Feature Collection Layer from a Feature Collection Table, and add it to a map.
CustomDictionaryStyleUse a custom dictionary style (.stylx) to symbolize features using a variety of attribute values.
DeleteFeaturesDelete features from an online feature service.
DisplayAnnotationDisplay annotation from a feature service URL.
DisplayDrawingStatusGet the draw status of your map view or scene view to know when all layers in the map or scene have finished drawing.
DisplayKmlLoad and display KML from a URL, a local file, or a portal item.
DisplayKmlNetworkLinks Display a file with a KML network link.
DisplayLayerViewStateView the status of the layers on the map.
DisplayWfsDisplay a layer from a WFS service, requesting only features for the current extent.
DistanceMeasurementMeasure distances between two points in 3D.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
EditFeatureAttachmentsAdd, delete, and download attachments for features from a service.
EditKmlGroundOverlayEdit the values of a KML ground overlay.
FeatureCollectionLayerFromPortalThis sample demonstrates opening a feature collection saved as a portal item.
FeatureCollectionLayerFromQueryCreate a feature collection layer to show a query result from a service feature table. The feature collection is then displayed on a map with a feature collection layer.
FeatureLayerDefinitionExpressionLimit the features to display on the map using a definition expression.
FeatureLayerDictionaryRendererConvert features into graphics to show them with mil2525d symbols.
FeatureLayerExtrusionExtrude features based on their attributes.
FeatureLayerGeodatabaseDisplay features from a local geodatabase.
FeatureLayerGeoPackageDisplay features from a local GeoPackage.
FeatureLayerQueryFind features in a feature table which match an SQL query.
FeatureLayerRenderingModeMapRender features statically or dynamically by setting the feature layer rendering mode.
FeatureLayerRenderingModeSceneRender features in a scene statically or dynamically by setting the feature layer rendering mode.
FeatureLayerSelectionSelect features in a feature layer.
FeatureLayerShapefileOpen a shapefile stored on the device and display it as a feature layer with default symbology.
FeatureLayerTimeOffsetShow data from the same service side-by-side with a time offset. This allows for the comparison of data over time.
FeatureLayerUrlShow a feature layer on a map using the URL to the service.
FindServiceAreasForMultipleFacilitiesFind the service areas of several facilities from a feature service.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GenerateOfflineMapWithOverridesUse the `OfflineMapTask` with overrides to take a webmap offline. The overrides workflow allows you to adjust the settings used for taking each layer in the map offline. For a simple example of how you take a map offline, please consult the "Generate Offline Map" sample.
GeodatabaseTransactionsThis sample demonstrates how to manage edits to a local geodatabase inside of transactions.
GroupLayersGroup a collection of layers together and toggle their visibility as a group.
IdentifyKmlFeaturesThis sample demonstrates how to identify features in a KML layer. Identified feature attributes are displayed in a callout to simulate a popup.
IdentifyLayersIdentify features in all layers in a map. MapView supports identifying features across multiple layers. Because some layer types have sublayers, the sample recursively counts results for sublayers within each layer.
LineOfSightGeoElementShow a line of sight between two moving objects.
ListKmlContentsList the contents of a KML file. KML files can contain a hierarchy of features, including network links to other KML content.
ListRelatedFeaturesList features related to the selected feature.
ManageOperationalLayersAdd, remove, and reorder operational layers in a map.
MapImageLayerTablesFind features in a spatial table related to features in a non-spatial table.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.
PlayKmlToursPlay tours in KML files.
QueryFeatureCountAndExtentZoom to features matching a query and count the features in the current visible extent.
RasterColormapRendererApply a colormap renderer to a raster.
RasterHillshadeUse a hillshade renderer on a raster.
RasterLayerFileCreate and use a raster layer made from a local raster file.
RasterLayerGeoPackageOpen a `GeoPackage`, obtain a raster from the package, and display the table as a `RasterLayer`.
RasterLayerImageServiceRasterCreate a raster layer from a raster image service.
RasterLayerRasterFunctionShow a raster layer from an image service with a raster function applied.
RasterRenderingRuleDisplay a raster on a map and apply different rendering rules to that raster.
RasterRgbRendererUse an `RGBRenderer` on a `RasterLayer`. An `RGBRenderer` is used to adjust the color bands of a multispectral image.
ReadGeoPackageAdd rasters and feature tables from GeoPackages to a map.
ReadShapefileMetadataRead a shapefile and display its metadata.
RenderUniqueValuesRender features in a layer using a distinct symbol for each unique attribute value.
SceneLayerSelectionIdentify GeoElements in a scene layer.
SceneLayerUrlDisplay an ArcGIS scene layer from a URL.
SelectEncFeaturesSelect features in an ENC layer.
ServiceFeatureTableCacheDisplay a feature layer from a service using the **on interaction cache** feature request mode.
ServiceFeatureTableManualCacheDisplay a feature layer from a service using the **manual cache** feature request mode.
ServiceFeatureTableNoCacheDisplay a feature layer from a service using the **no cache** feature request mode.
SetMapSpatialReferenceSpecify a map's spatial reference.
ShowLabelsOnLayerDisplay custom labels on a feature layer.
StatisticalQueryQuery a table to get aggregated statistics back for a specific field.
StyleWmsLayerDiscover available styles and apply them to WMS sublayers.
SymbolizeShapefileDisplay a shapefile with custom symbology.
TimeBasedQueryThis sample demonstrates how to query data using a time extent. This workflow can be used to return records that are between a specified start and end date. For example, you could specify to only show records that are before September 16, 2000.
TokenSecuredChallengeThis sample demonstrates how to prompt the user for a username and password to authenticate with ArcGIS Server to access an ArcGIS token-secured service. Accessing secured services requires a login that's been defined on the server.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
UpdateAttributesUpdate feature attributes in an online feature service.
UpdateGeometriesUpdate a feature's location in an online feature service.
ViewPointCloudDataOfflineDisplay local 3D point cloud data.
ViewshedCameraAnalyze the viewshed for a camera. A viewshed shows the visible and obstructed areas from an observer's vantage point.
ViewshedGeoElementAnalyze the viewshed for an object (GeoElement) in a scene.
ViewshedLocationPerform a viewshed analysis from a defined vantage point. Viewshed analyses have several configuration options that are demonstrated in this sample.
WfsXmlQueryLoad a WFS feature table using an XML query.
WmsIdentifyIdentify features in a WMS layer and display the associated popup content.
WMSLayerUrlDisplay a WMS layer using a WMS service URL.
WmsServiceCatalogConnect to a WMS service and show the available layers and sublayers. Layers are shown in a hierarchy. Selecting a group layer will recursively select all sublayers for display.
WMTSLayerDisplay a layer from a Web Map Tile Service.