Click or drag to resize

Layer Class

This is the base class for all layer types that can be added to the Map document.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingLayer
    More...

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public abstract class Layer : ILoadable, 
	ILayerContent

The Layer type exposes the following members.

Properties
  NameDescription
Public propertyAttribution
Gets the attribution text for the layer.
Public propertyCanChangeVisibility
Gets a value indicating whether the layer content's visibility can be changed.
Public propertyDescription
Gets the description for the layer.
Public propertyCode exampleFullExtent
Gets the full extent of the layer, which is the extent where all the data in the layer is contained.
Public propertyCode exampleId
Gets or sets an identifier for the layer
Public propertyIsIdentifyEnabled
Gets a value indicating whether the layer supports the identify operation.
Public propertyCode exampleIsVisible
Gets or sets a value indicating whether the layer content is visible.
Public propertyItem
Gets the ArcGIS Item
Public propertyLoadError
Gets the load error of the layer, if there is one.
Public propertyCode exampleLoadStatus
Gets the load status of the layer.
Public propertyCode exampleMaxScale
Gets or sets the maximum scale where the layer is visible.
Public propertyCode exampleMinScale
Gets or sets the minimum scale where the layer is visible.
Public propertyCode exampleName
Gets or sets the name of the layer content.
Public propertyCode exampleOpacity
Gets or sets the opacity of the layer.
Public propertyShowInLegend
Gets or sets a value indicating whether the layer content participates in the legend.
Public propertySpatialReference
Gets the spatial reference of the layer.
Public propertyCode exampleSublayerContents
Gets the sub layer contents of a layer content.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancels an ongoing load.
Public methodCode exampleClone
Clones this instance of Layer and its members.
Public methodGetLegendInfosAsync
Returns an immutable list of LegendInfo.
Public methodIsVisibleAtScale
Returns the layer content's effective visibility at the specified scale.
Public methodCode exampleLoadAsync
Initiates loading of a layer
Protected methodOnPropertyChanged
Called when a property changes.
Public methodRetryLoadAsync
Retry loading the layer.
Top
Events
  NameDescription
Public eventCode exampleLoaded
Occurs when the layer is loaded.
Public eventCode exampleLoadStatusChanged
Occurs when the layer LoadStatus is changed.
Public eventPropertyChanged
Occurs when a property value changes.
Top
Remarks

A Layer is a representation of geographic data portrayed using symbols and text labels. Multiple Layers can be ‘stacked’ on top of each other to enhance the information displayed for making meaningful decisions. Layers are displayed visually in the Map Control. Layers are drawn bottom to top so the first one in the LayerCollection is drawn first (on the bottom) and each subsequent layer is drawn on top of it, in the order listed.

Examples

Android

Example Name: RasterLayerFile

Create and use a raster layer made from a local raster file.

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 Android.App;
using Android.OS;
using Android.Widget;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Rasters;
using Esri.ArcGISRuntime.UI.Controls;
using ArcGISRuntime.Samples.Managers;

namespace ArcGISRuntime.Samples.RasterLayerFile
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("7c4c679ab06a4df19dc497f577f111bd")]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (file)",
        "Layers",
        "This sample demonstrates how to use a raster layer created from a local raster file.",
        "The raster file is downloaded by the sample viewer automatically. Note that due to a known bug, this sample may crash in emulators running Android 4.4 (API level 19). All other platform versions are unaffected.")]
    public class RasterLayerFile : Activity
    {
        // Reference to the MapView used in the sample
        private MapView _myMapView;

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

            Title = "Raster layer (file)";

            // Create the layout
            CreateLayout();

            // Initialize the app
            Initialize();
        }

        private void CreateLayout()
        {
            // Create a stack layout
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add the mapview to the layout
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

            // Set the layout as the sample view
            SetContentView(layout);
        }

        private async void Initialize()
        {
            // Add an imagery basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

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

            // Add map to the mapview
            _myMapView.Map = myMap;

            try
            {
                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                // Set the viewpoint
                await _myMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        private string GetRasterPath()
        {
            return DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif");
        }
    }
}
Examples

Xamarin Forms Android

Example Name: RasterLayerFile

Create and use a raster layer made from a local raster file.

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 Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Rasters;
using ArcGISRuntime.Samples.Managers;
using Xamarin.Forms;

namespace ArcGISRuntime.Samples.RasterLayerFile
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Raster layer (file)",
        "Layers",
        "This sample demonstrates how to use a raster layer created from a local raster file.",
        "The raster file is downloaded by the sample viewer automatically. Note that due to a known bug, this sample may crash in emulators running Android 4.4 (API level 19). All other platform versions are unaffected.")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("7c4c679ab06a4df19dc497f577f111bd")]
    public partial class RasterLayerFile : ContentPage
    {
        public RasterLayerFile()
        {
            InitializeComponent();

            // Call a function to set up the map
            Initialize();
        }

        private async void Initialize()
        {
            // Add an imagery basemap
            Map myMap = new Map(Basemap.CreateImagery());

            // Get the file name
            string filepath = GetRasterPath();

            // Load the raster file
            Raster myRasterFile = new Raster(filepath);

            // Create the layer
            RasterLayer myRasterLayer = new RasterLayer(myRasterFile);

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

            // Add map to the mapview
            MyMapView.Map = myMap;

            try
            {
                // Wait for the layer to load
                await myRasterLayer.LoadAsync();

                // Set the viewpoint
                await MyMapView.SetViewpointGeometryAsync(myRasterLayer.FullExtent);
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }

        private string GetRasterPath()
        {
            return DataManager.GetDataFolder("7c4c679ab06a4df19dc497f577f111bd", "raster-file", "Shasta.tif");
        }
    }
}
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"
    x:Class="ArcGISRuntime.Samples.RasterLayerFile.RasterLayerFile"
             Title="Raster layer (file)">

    <Grid>
        <esriUI:MapView x:Name="MyMapView"/>
    </Grid>
</ContentPage>
See Also
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingLayer
    Esri.ArcGISRuntime.MappingAnnotationLayer
    Esri.ArcGISRuntime.MappingArcGISSceneLayer
    Esri.ArcGISRuntime.MappingArcGISVectorTiledLayer
    Esri.ArcGISRuntime.MappingEncLayer
    Esri.ArcGISRuntime.MappingFeatureCollectionLayer
    Esri.ArcGISRuntime.MappingFeatureLayer
    Esri.ArcGISRuntime.MappingGroupLayer
    Esri.ArcGISRuntime.MappingImageAdjustmentLayer
    Esri.ArcGISRuntime.MappingIntegratedMeshLayer
    Esri.ArcGISRuntime.MappingKmlLayer
    Esri.ArcGISRuntime.MappingMobileBasemapLayer
    Esri.ArcGISRuntime.MappingOpenStreetMapLayer
    Esri.ArcGISRuntime.MappingPointCloudLayer
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.
ArcGISVectorTiledLayerUrlLoad an ArcGIS Vector 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.
ChangeBlendRendererBlend a hillshade with a raster by specifying the elevation data. The resulting raster looks similar to the original raster, but with some terrain shading, giving it a textured look.
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.
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.
DownloadPreplannedMapTake a map offline using an available preplanned map area.
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.
ExportTilesDownload tiles to a local tile cache file stored on the device.
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.
GenerateOfflineMapTake a web map offline.
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.
LoadWebTiledLayerDisplay a tiled web layer.
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.
OfflineBasemapByReferenceUse the `OfflineMapTask` to take a web map offline, but instead of downloading an online basemap, use one which is already on the device.
OfflineGeocodeGeocode addresses to locations and reverse geocode locations to addresses offline.
OfflineRoutingSolve a route on-the-fly using offline data.
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.