Click or drag to resize

ViewpointTargetGeometry Property

Gets the target geometry this view is requesting.

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
public Geometry TargetGeometry { get; }

Property Value

Type: Geometry
The spatial reference of the target geometry cannot be null.


Example Name: MapImageSublayerQuery

Find features in a sublayer based on attributes and location.

Code example screen shot.

// 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:
// 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 System.Drawing;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.MapImageSublayerQuery
        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 click 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
        // Use a private variable to reference the graphics overlay for showing selected features.
        private GraphicsOverlay _selectedFeaturesOverlay;

        public MapImageSublayerQuery()

            // Initialize the map to show the USA map image layer. 

        private void Initialize()
            // Create a new Map with a vector streets basemap.
            Map myMap = new Map(BasemapStyle.ArcGISStreets);

            // 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("");

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

            // Add the layer to the map.

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

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

        private async void QuerySublayers_Click(object sender, System.Windows.RoutedEventArgs e)
            // Clear selected features from the graphics overlay.

            // 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");

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

                // 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);


                // 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);


                // 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);

            catch (Exception ex)
                MessageBox.Show(ex.ToString(), "Error");
<UserControl x:Class="ArcGISRuntime.WPF.Samples.MapImageSublayerQuery.MapImageSublayerQuery"
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                <TextBlock Grid.Row="0" Grid.Column="0"
                           HorizontalAlignment="Right" VerticalAlignment="Center"
                           Text="[POP2000] > " />
                <TextBox x:Name="PopulationTextBox"
                         Grid.Row="0" Grid.Column="1"
                         HorizontalAlignment="Stretch" VerticalAlignment="Center" HorizontalContentAlignment="Center"
                         Text="1810000" />
                <Button x:Name="QuerySublayers"
                        Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"
                        Content="Query in extent"
                        Click="QuerySublayers_Click" />
See Also
Additional Examples
Hyperlink to ExampleDescription
AuthorMapCreate and save a map as an ArcGIS `PortalItem` (i.e. web map).
DisplayUtilityAssociationsCreate graphics for utility associations in a utility network.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
ListKmlContentsList the contents of a KML file.
ListTransformationsGet a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.
QueryFeatureCountAndExtentZoom to features matching a query and count the features in the current visible extent.
StatisticalQueryQuery a table to get aggregated statistics back for a specific field.