Click or drag to resize

ArcGISMapImageSublayer Class

An ArcGIS map image sublayer.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingArcGISSublayer
    Esri.ArcGISRuntime.MappingArcGISMapImageSublayer

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.9.0.0
Syntax
C#
public sealed class ArcGISMapImageSublayer : ArcGISSublayer

The ArcGISMapImageSublayer type exposes the following members.

Constructors
  NameDescription
Public methodArcGISMapImageSublayer(Int64)
Initializes a new instance of the ArcGISMapImageSublayer class with the specified sublayer id.
Public methodArcGISMapImageSublayer(Int64, SublayerSource)
Initializes a new instance of the ArcGISMapImageSublayer class with the specified sublayer id and source.
Top
Properties
  NameDescription
Public propertyCanChangeVisibility
Gets a value indicating whether the sublayer content's visibility can be changed.
(Inherited from ArcGISSublayer.)
Public propertyDefaultVisibility
Gets a value indicating whether gets this sublayer's default visibility.
Public propertyDefinitionExpression
Gets or sets the definition expression of this map image sublayer.
Public propertyId
Gets an id that uniquely identifies this sublayer instance.
(Inherited from ArcGISSublayer.)
Public propertyIsPopupEnabled
Gets or sets a value indicating whether the PopupDefinition defined is enabled.
(Inherited from ArcGISSublayer.)
Public propertyCode exampleIsVisible
Gets or sets a value indicating whether the sublayer content is visible.
(Inherited from ArcGISSublayer.)
Public propertyLabelDefinitions
Gets a modifiable collection of label definitions for this sublayer. Only available if the ArcGISMapImageLayer supports dynamic capabilities.
Public propertyLabelsEnabled
Gets or sets a value indicating whether labels should be displayed on this sublayer.
Public propertyLoadError
Gets the Exception associated with the last load error.
(Inherited from ArcGISSublayer.)
Public propertyLoadStatus
Gets the load status.
(Inherited from ArcGISSublayer.)
Public propertyMapServiceSublayerInfo
Gets this sublayer's metadata.
(Inherited from ArcGISSublayer.)
Public propertyMaxScale
Gets or sets the maximum scale at which this sublayer is visible.
Public propertyMinScale
Gets or sets the minimum scale at which this sublayer is visible.
Public propertyName
Gets or sets the name of the sublayer.
Public propertyOpacity
Gets or sets the opacity of this sublayer.
Public propertyPopupDefinition
Gets or sets the popup definition for the sublayer.
(Inherited from ArcGISSublayer.)
Public propertyCode exampleRenderer
Gets or sets this sublayer's Renderer.
Public propertyScaleSymbols
Gets or sets a value indicating whether this sublayer renders its symbols based on scale.
Public propertyShowInLegend
Gets or sets a value indicating whether the sublayer participates in the legend.
(Inherited from ArcGISSublayer.)
Public propertySource
Gets the SublayerSource of this sublayer.
Public propertySublayerContents
Gets a read-only collection of ILayerContent for this sublayer.
(Inherited from ArcGISSublayer.)
Public propertySublayers
Gets the sublayers of this sublayer.
(Inherited from ArcGISSublayer.)
Public propertyCode exampleTable
Gets the sublayer feature table.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancel loading metadata for the object.
(Inherited from ArcGISSublayer.)
Public methodClone
Clones this instance of the ArcGISSublayer and its members.
(Inherited from ArcGISSublayer.)
Public methodGetLegendInfosAsync
Asynchronously retrieves a read-only list of LegendInfo objects.
(Inherited from ArcGISSublayer.)
Public methodIsVisibleAtScale
Retrieves the sublayer's visibility at the specified scale.
(Inherited from ArcGISSublayer.)
Public methodLoadAsync
Load the metadata for the object asynchronously.
(Inherited from ArcGISSublayer.)
Public methodRetryLoadAsync
Load the metadata for the object asynchronously.
(Inherited from ArcGISSublayer.)
Public methodSetName
Sets the map image sublayer's name.
Top
Events
  NameDescription
Public eventLoaded
Event that is raised when the object is done loading.
(Inherited from ArcGISSublayer.)
Public eventLoadStatusChanged
Event that is raised when the LoadStatus property changes.
(Inherited from ArcGISSublayer.)
Top
Remarks

ArcGISMapImageLayer displays maps from an ArcGIS map server. Each layer in the underlying map service is represented by an ArcGISSublayer. You can control the visibility and symbology of sub-layers and filter data with layer definition expressions.

You can get an instance of this class from Sublayers once the map image layer is loaded or you can get a collection of sub-layers from another map image sublayer by using Sublayers. You can also create a new sub-layer using the ArcGISMapImageSublayer(Int64) or ArcGISMapImageSublayer(Int64, SublayerSource) constructors.

Examples

Android

Example Name: MapImageSublayerQuery

Find features in a sublayer based on attributes and location.

Code example screen shot.

C#
// Copyright 2018 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 Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
using Esri.ArcGISRuntime.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Drawing;

namespace ArcGISRuntime.Samples.MapImageSublayerQuery
{
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Query map image sublayer",
        category: "Layers",
        description: "Find features in a sublayer based on attributes and location.",
        instructions: "Specify a minimum population in the input field (values under 1810000 will produce a selection in all layers) and tap the query button to query the sublayers in the current view extent. After a short time, the results for each sublayer will appear as graphics.",
        tags: new[] { "search and query" })]
    public class MapImageSublayerQuery : Activity
    {
        // Hold a reference to the map view.
        private MapView _myMapView;

        // Use a private variable to reference the graphics overlay for showing selected features.
        private GraphicsOverlay _selectedFeaturesOverlay;

        // A text input for the population value to query with.
        private EditText _populationValueInput;

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

            Title = "Query a map image sublayer";

            // Create the UI and initialize the map.
            CreateLayout();
            Initialize();
        }

        private void Initialize()
        {
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create and set the map's initial view point.
            MapPoint initialLocation = new MapPoint(-12716000.00, 4170400.00, SpatialReferences.WebMercator);
            myMap.InitialViewpoint = new Viewpoint(initialLocation, 6000000);

            // Create the URI to the USA map service.
            Uri usaServiceUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");

            // Create a new ArcGISMapImageLayer that uses the service URI.
            ArcGISMapImageLayer usaMapImageLayer = new ArcGISMapImageLayer(usaServiceUri);

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

            // Assign the map to the MapView.
            _myMapView.Map = myMap;

            // Add a graphics overlay to show selected features.
            _selectedFeaturesOverlay = new GraphicsOverlay();
            _myMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay);
        }

        private async void QuerySublayers_Click(object sender, EventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // If the population value entered is not numeric, warn the user and exit.
            double populationNumber = 0.0;
            if (!double.TryParse(_populationValueInput.Text.Trim(), out populationNumber))
            {
                Toast messageToast = Toast.MakeText(this.ApplicationContext, "Population value must be numeric.", ToastLength.Short);
                messageToast.Show();

                return;
            }

            // Get the USA map image layer (the first and only operational layer in the map).
            ArcGISMapImageLayer usaMapImageLayer = (ArcGISMapImageLayer)_myMapView.Map.OperationalLayers[0];

            try
            {
                // Use a utility method on the map image layer to load all the sublayers and tables.
                await usaMapImageLayer.LoadTablesAndLayersAsync();

                // Get the sublayers of interest (skip 'Highways' since it doesn't have the POP2000 field).
                ArcGISMapImageSublayer citiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[0];
                ArcGISMapImageSublayer statesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[2];
                ArcGISMapImageSublayer countiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[3];

                // Get the service feature table for each of the sublayers.
                ServiceFeatureTable citiesTable = citiesSublayer.Table;
                ServiceFeatureTable statesTable = statesSublayer.Table;
                ServiceFeatureTable countiesTable = countiesSublayer.Table;

                // Create the query parameters that will find features in the current extent with a population greater than the value entered.
                QueryParameters populationQuery = new QueryParameters
                {
                    WhereClause = "POP2000 > " + _populationValueInput.Text,
                    Geometry = _myMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry
                };

                // Query each of the sublayers with the query parameters.
                FeatureQueryResult citiesQueryResult = await citiesTable.QueryFeaturesAsync(populationQuery);
                FeatureQueryResult statesQueryResult = await statesTable.QueryFeaturesAsync(populationQuery);
                FeatureQueryResult countiesQueryResult = await countiesTable.QueryFeaturesAsync(populationQuery);

                // Display the selected cities in the graphics overlay.
                SimpleMarkerSymbol citySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 16);
                foreach (Feature city in citiesQueryResult)
                {
                    Graphic cityGraphic = new Graphic(city.Geometry, citySymbol);

                    _selectedFeaturesOverlay.Graphics.Add(cityGraphic);
                }

                // Display the selected counties in the graphics overlay.
                SimpleLineSymbol countyLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Cyan, 2);
                SimpleFillSymbol countySymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Color.Cyan, countyLineSymbol);
                foreach (Feature county in countiesQueryResult)
                {
                    Graphic countyGraphic = new Graphic(county.Geometry, countySymbol);

                    _selectedFeaturesOverlay.Graphics.Add(countyGraphic);
                }

                // Display the selected states in the graphics overlay.
                SimpleLineSymbol stateLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkCyan, 6);
                SimpleFillSymbol stateSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, Color.Cyan, stateLineSymbol);
                foreach (Feature state in statesQueryResult)
                {
                    Graphic stateGraphic = new Graphic(state.Geometry, stateSymbol);

                    _selectedFeaturesOverlay.Graphics.Add(stateGraphic);
                }
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.ToString()).SetTitle("Error").Show();
            }
        }

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

            // Create a horizontal layout for the query controls.
            LinearLayout populationInputLayout = new LinearLayout(this) { Orientation = Orientation.Horizontal };

            // Create parameters for the button.
            LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent,
                ViewGroup.LayoutParams.MatchParent,
                1.0f
            );

            // Create the population query controls: a label, a text input, and a button to execute the query.
            TextView populationLabel = new TextView(this) { Text = "[POP2000] > " };
            _populationValueInput = new EditText(this) { Text = "1800000" };
            _populationValueInput.SetMinimumWidth(200);
            Button queryButton = new Button(this) { Text = "Query", LayoutParameters = param };

            // Create some space.
            Space space = new Space(this);
            space.SetMinimumWidth(50);

            // Add the controls to the horizontal layout.
            populationInputLayout.AddView(space);
            populationInputLayout.AddView(populationLabel);
            populationInputLayout.AddView(_populationValueInput);
            populationInputLayout.AddView(queryButton);

            // Wire the event handler for the query button click.
            queryButton.Click += QuerySublayers_Click;

            // Add the query controls and map view to the app layout.
            layout.AddView(populationInputLayout);
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

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

Xamarin Forms Android

Example Name: MapImageSublayerQuery

Find features in a sublayer based on attributes and location.

Code example screen shot.

C#
// Copyright 2018 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.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using Xamarin.Forms;
using Color = System.Drawing.Color;

namespace ArcGISRuntime.Samples.MapImageSublayerQuery
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Query map image sublayer",
        category: "Layers",
        description: "Find features in a sublayer based on attributes and location.",
        instructions: "Specify a minimum population in the input field (values under 1810000 will produce a selection in all layers) and tap the query button to query the sublayers in the current view extent. After a short time, the results for each sublayer will appear as graphics.",
        tags: new[] { "search and query" })]
    public partial class MapImageSublayerQuery : ContentPage
    {
        // Use a private variable to reference the graphics overlay for showing selected features.
        private GraphicsOverlay _selectedFeaturesOverlay;

        public MapImageSublayerQuery()
        {
            InitializeComponent ();

            // Initialize the map to show the USA map image layer. 
            Initialize();
        }

        private void Initialize()
        {
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(Basemap.CreateStreetsVector());

            // Create and set the map's initial view point.
            MapPoint initialLocation = new MapPoint(-12716000.00, 4170400.00, SpatialReferences.WebMercator);
            myMap.InitialViewpoint = new Viewpoint(initialLocation, 6000000);

            // Create the URI to the USA map service.
            Uri usaServiceUri = new Uri("https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");

            // Create a new ArcGISMapImageLayer that uses the service URI.
            ArcGISMapImageLayer usaMapImageLayer = new ArcGISMapImageLayer(usaServiceUri);

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

            // Assign the map to the MapView.
            MyMapView.Map = myMap;

            // Add a graphics overlay to show selected features.
            _selectedFeaturesOverlay = new GraphicsOverlay();
            MyMapView.GraphicsOverlays.Add(_selectedFeaturesOverlay);
        }

        private async void QuerySublayers_Click(object sender, EventArgs e)
        {
            // Clear selected features from the graphics overlay.
            _selectedFeaturesOverlay.Graphics.Clear();

            // If the population value entered is not numeric, warn the user and exit.
            double populationNumber = 0.0;
            if (!double.TryParse(PopulationTextBox.Text.Trim(), out populationNumber))
            {
            //    MessageBox.Show("The population value must be numeric.", "Query error");
                return;
            }

            // Get the USA map image layer (the first and only operational layer in the map).
            ArcGISMapImageLayer usaMapImageLayer = (ArcGISMapImageLayer)MyMapView.Map.OperationalLayers[0];

            try
            {
                // Use a utility method on the map image layer to load all the sublayers and tables.
                await usaMapImageLayer.LoadTablesAndLayersAsync();

                // Get the sublayers of interest (skip 'Highways' since it doesn't have the POP2000 field).
                ArcGISMapImageSublayer citiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[0];
                ArcGISMapImageSublayer statesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[2];
                ArcGISMapImageSublayer countiesSublayer = (ArcGISMapImageSublayer)usaMapImageLayer.Sublayers[3];

                // Get the service feature table for each of the sublayers.
                ServiceFeatureTable citiesTable = citiesSublayer.Table;
                ServiceFeatureTable statesTable = statesSublayer.Table;
                ServiceFeatureTable countiesTable = countiesSublayer.Table;

                // Create the query parameters that will find features in the current extent with a population greater than the value entered.
                QueryParameters populationQuery = new QueryParameters
                {
                    WhereClause = "POP2000 > " + PopulationTextBox.Text,
                    Geometry = MyMapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry
                };

                // Query each of the sublayers with the query parameters.
                FeatureQueryResult citiesQueryResult = await citiesTable.QueryFeaturesAsync(populationQuery);
                FeatureQueryResult statesQueryResult = await statesTable.QueryFeaturesAsync(populationQuery);
                FeatureQueryResult countiesQueryResult = await countiesTable.QueryFeaturesAsync(populationQuery);

                // Display the selected cities in the graphics overlay.
                SimpleMarkerSymbol citySymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Red, 16);
                foreach (Feature city in citiesQueryResult)
                {
                    Graphic cityGraphic = new Graphic(city.Geometry, citySymbol);

                    _selectedFeaturesOverlay.Graphics.Add(cityGraphic);
                }

                // Display the selected counties in the graphics overlay.
                SimpleLineSymbol countyLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, Color.Cyan, 2);
                SimpleFillSymbol countySymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.DiagonalCross, Color.Cyan, countyLineSymbol);
                foreach (Feature county in countiesQueryResult)
                {
                    Graphic countyGraphic = new Graphic(county.Geometry, countySymbol);

                    _selectedFeaturesOverlay.Graphics.Add(countyGraphic);
                }

                // Display the selected states in the graphics overlay.
                SimpleLineSymbol stateLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.DarkCyan, 6);
                SimpleFillSymbol stateSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Null, Color.Cyan, stateLineSymbol);
                foreach (Feature state in statesQueryResult)
                {
                    Graphic stateGraphic = new Graphic(state.Geometry, stateSymbol);

                    _selectedFeaturesOverlay.Graphics.Add(stateGraphic);
                }
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error", ex.ToString(), "OK");
            }
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="ArcGISRuntime.Samples.MapImageSublayerQuery.MapImageSublayerQuery"
    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">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Frame
            Margin="20"
            BackgroundColor="White"
            HorizontalOptions="Center"
            VerticalOptions="Start"
            WidthRequest="250">
            <Grid Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Label
                    Grid.Row="0"
                    Grid.Column="0"
                    Margin="2"
                    HorizontalOptions="End"
                    Text="[POP2000] &gt; "
                    VerticalOptions="Center">
                    <Label.TextColor>
                        <OnPlatform x:TypeArguments="Color">
                            <On Platform="Android" Value="DarkBlue" />
                        </OnPlatform>
                    </Label.TextColor>
                </Label>
                <Entry
                    x:Name="PopulationTextBox"
                    Grid.Row="0"
                    Grid.Column="1"
                    Margin="2"
                    HorizontalOptions="Fill"
                    HorizontalTextAlignment="End"
                    Text="1810000"
                    VerticalOptions="Center">
                    <Entry.TextColor>
                        <OnPlatform x:TypeArguments="Color">
                            <On Platform="Android" Value="DarkBlue" />
                        </OnPlatform>
                    </Entry.TextColor>
                </Entry>
                <Button
                    x:Name="QuerySublayers"
                    Grid.Row="1"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="2"
                    Clicked="QuerySublayers_Click"
                    Text="Query in extent"
                    VerticalOptions="Center" />
            </Grid>
        </Frame>
    </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
ChangeSublayerRendererApply a renderer to a sublayer.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.