Click or drag to resize

GeoElementGeometry Property

Gets the geometry of a GeoElement.

Namespace:  Esri.ArcGISRuntime.Data
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version:
public abstract Geometry Geometry { get; set; }

Property Value

Type: Geometry


Example Name: DeleteFeatures

Delete features from an online feature service.

Code example screen shot.

// Copyright 2019 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 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.UI.Controls;
using System;
using System.Linq;

namespace ArcGISRuntimeXamarin.Samples.DeleteFeatures
    [Activity (ConfigurationChanges=Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
        name: "Delete features (feature service)",
        category: "Data",
        description: "Delete features from an online feature service.",
        instructions: "To delete a feature, tap it, then tap 'Delete incident'.",
        tags: new[] { "Service", "deletion", "feature", "online", "table" })]
    public class DeleteFeatures : Activity
        // Hold a reference to the MapView.
        private MapView _myMapView;

        // URL to the feature service.
        private const string FeatureServiceUrl = "";

        // Hold a reference to the feature layer.
        private FeatureLayer _damageLayer;

        protected override void OnCreate(Bundle bundle)

            Title = "Delete features";


        private void Initialize()
            // Create the map with streets basemap.
            _myMapView.Map = new Map(Basemap.CreateStreets());

            // Create the feature table, referring to the Damage Assessment feature service.
            ServiceFeatureTable damageTable = new ServiceFeatureTable(new Uri(FeatureServiceUrl));

            // Create a feature layer to visualize the features in the table.
            _damageLayer = new FeatureLayer(damageTable);

            // Add the layer to the map.

            // Listen for user taps on the map - on tap, a callout will be shown.
            _myMapView.GeoViewTapped += MapView_Tapped;

            // Zoom to the United States.
            _myMapView.SetViewpointCenterAsync(new MapPoint(-10800000, 4500000, SpatialReferences.WebMercator), 3e7);

        private async void MapView_Tapped(object sender, GeoViewInputEventArgs e)
            // Clear any existing selection.

            // Dismiss any existing callouts.

                // Perform an identify to determine if a user tapped on a feature.
                IdentifyLayerResult identifyResult = await _myMapView.IdentifyLayerAsync(_damageLayer, e.Position, 8, false);

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())

                // Otherwise, get the ID of the first result.
                long featureId = (long) identifyResult.GeoElements.First().Attributes["objectid"];

                // Get the feature by constructing a query and running it.
                QueryParameters qp = new QueryParameters();
                FeatureQueryResult queryResult = await _damageLayer.FeatureTable.QueryFeaturesAsync(qp);
                Feature tappedFeature = queryResult.First();

                // Select the feature.

                // Show the callout.
            catch (Exception ex)
                ShowMessage(ex.ToString(), "There was a problem.");

        private void ShowDeletionCallout(Feature tappedFeature)
            // Create a button for deleting the feature.
            Button deleteButton = new Button(this);
            deleteButton.Text = "Delete feature";

            // Handle button clicks.
            deleteButton.Click += (o, e) => { DeleteFeature(tappedFeature); };

            // Show the callout.
            _myMapView.ShowCalloutAt((MapPoint) tappedFeature.Geometry, deleteButton);

        private async void DeleteFeature(Feature featureToDelete)
            // Dismiss the callout.

                // Delete the feature.
                await _damageLayer.FeatureTable.DeleteFeatureAsync(featureToDelete);

                // Sync the change with the service.
                ServiceFeatureTable serviceTable = (ServiceFeatureTable) _damageLayer.FeatureTable;
                await serviceTable.ApplyEditsAsync();

                // Show a message confirming the deletion.
                ShowMessage($"Deleted feature with ID {featureToDelete.Attributes["objectid"]}", "Success!");
            catch (Exception ex)
                ShowMessage(ex.ToString(), "Couldn't delete feature");

        private void ShowMessage(string message, string title)
            // Display the message to the user.
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

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

            // Create the MapView.
            _myMapView = new MapView(this);

            // Create the help label.
            TextView helpLabel = new TextView(this);
            helpLabel.Text = "Tap to select a feature for deletion.";
            helpLabel.TextAlignment = TextAlignment.Center;
            helpLabel.Gravity = GravityFlags.Center;

            // Add the help label to the layout.

            // Add the map view to the layout.

            // Show the layout in the app.

Xamarin Forms Android

Example Name: FeatureLayerQuery

Find features in a feature table which match an SQL query.

Code example screen shot.

// Copyright 2016 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms;
using Color = System.Drawing.Color;

namespace ArcGISRuntime.Samples.FeatureLayerQuery
        name: "Feature layer query",
        category: "Data",
        description: "Find features in a feature table which match an SQL query.",
        instructions: "Input the name of a U.S. state into the text field. When you tap the button, a query is performed and the matching features are highlighted or an error is returned.",
        tags: new[] { "query", "search" })]
    public partial class FeatureLayerQuery : ContentPage
        // Create reference to service of US States
        private string _statesUrl = "";

        // Create globally available feature table for easy referencing
        private ServiceFeatureTable _featureTable;

        // Create globally available feature layer for easy referencing
        private FeatureLayer _featureLayer;

        public FeatureLayerQuery()

            // Create the UI, setup the control references and execute initialization

        private void Initialize()
            // Create new Map with basemap
            Map myMap = new Map(Basemap.CreateTopographic());

            // Create and set initial map location
            MapPoint initialLocation = new MapPoint(
                -11000000, 5000000, SpatialReferences.WebMercator);
            myMap.InitialViewpoint = new Viewpoint(initialLocation, 100000000);

            // Create feature table using a url
            _featureTable = new ServiceFeatureTable(new Uri(_statesUrl));

            // Create feature layer using this feature table
            _featureLayer = new FeatureLayer(_featureTable)
                // Set the Opacity of the Feature Layer
                Opacity = 0.6,
                // Work around service setting
                MaxScale = 10

            // Create a new renderer for the States Feature Layer.
            SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1);
            SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, Color.Transparent, lineSymbol);

            // Set States feature layer renderer
            _featureLayer.Renderer = new SimpleRenderer(fillSymbol);

            // Add feature layer to the map

            // Set the selection color
            myMapView.SelectionProperties.Color = Color.Cyan;

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

        private async void OnQueryClicked(object sender, EventArgs e)
            // Remove any previous feature selections that may have been made

            // Begin query process
            await QueryStateFeature(queryEntry.Text);

        private async Task QueryStateFeature(string stateName)
                // Create a query parameters that will be used to Query the feature table
                QueryParameters queryParams = new QueryParameters();

                // Trim whitespace on the state name to prevent broken queries
                string formattedStateName = stateName.Trim().ToUpper();

                // Construct and assign the where clause that will be used to query the feature table
                queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + formattedStateName + "%'";

                // Query the feature table
                FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);

                // Cast the QueryResult to a List so the results can be interrogated.
                List<Feature> features = queryResult.ToList();

                if (features.Any())
                    // Create an envelope.
                    EnvelopeBuilder envBuilder = new EnvelopeBuilder(SpatialReferences.WebMercator);

                    // Loop over each feature from the query result.
                    foreach (Feature feature in features)
                        // Add the extent of each matching feature to the envelope.

                        // Select each feature.

                    // Zoom to the extent of the selected feature(s).
                    await myMapView.SetViewpointGeometryAsync(envBuilder.ToGeometry(), 50);
                    await Application.Current.MainPage.DisplayAlert("State Not Found!", "Add a valid state name.", "OK");
            catch (Exception)
                await Application.Current.MainPage.DisplayAlert("Sample error", "An error occurred", "OK");
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns=""
      <RowDefinition Height="auto" />
      <RowDefinition Height="*" />
    <StackLayout Orientation="Vertical">
      <Entry x:Name="queryEntry" Text="New York"/>
      <Button Text="Query" Clicked="OnQueryClicked"/>
    <esriUI:MapView x:Name="myMapView"  Grid.Row="1"/>
See Also
Additional Examples
Hyperlink to ExampleDescription
AddFeaturesAdd features to a feature layer.
AddGraphicsWithSymbolsUse a symbol style to display a graphic on a graphics overlay.
AnalyzeViewshedCalculate a viewshed using a geoprocessing service, in this case showing what parts of a landscape are visible from points on mountainous terrain.
Animate3DGraphicAn `OrbitGeoElementCameraController` follows a graphic while the graphic's position and rotation are animated.
BufferListGenerate multiple individual buffers or a single unioned buffer around multiple points.
ClipGeometryClip a geometry with another geometry.
ClosestFacilityStaticFind routes from several locations to the respective closest facility.
ConvexHullListGenerate convex hull polygon(s) from multiple input geometries.
CreateFeatureCollectionLayerCreate a Feature Collection Layer from a Feature Collection Table, and add it to a map.
CutGeometryCut a geometry along a polyline.
DensifyAndGeneralizeA multipart geometry can be densified by adding interpolated points at regular intervals. Generalizing multipart geometry simplifies it while preserving its general shape. Densifying a multipart geometry adds more vertices at regular intervals.
DictionaryRendererGraphicsOverlayThis sample demonstrates applying a dictionary renderer to graphics, in order to display military symbology without the need for a feature table.
EditAndSyncFeaturesSynchronize offline edits with a feature service.
ExportTilesDownload tiles to a local tile cache file stored on the device.
FeatureLayerQueryFind features in a feature table which match an SQL query.
FindRouteDisplay directions for a route between two points.
FindServiceAreaFind the service area within a network from a given point.
GenerateGeodatabaseGenerate a local geodatabase from an online feature service.
GeodatabaseTransactionsUse transactions to manage how changes are committed to a geodatabase.
GeodesicOperationsCalculate a geodesic path between two points and measure its distance.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
IdentifyRasterCellGet the cell value of a local raster at the tapped location and display the result in a callout.
LineOfSightGeoElementShow a line of sight between two moving objects.
ListTransformationsGet a list of suitable transformations for projecting a geometry between two spatial references with different horizontal datums.
MapImageLayerTablesFind features in a spatial table related to features in a non-spatial table.
MapImageSublayerQueryFind features in a sublayer based on attributes and location.
NavigateRouteUse a routing service to navigate between points.
NavigateRouteReroutingNavigate between two points and dynamically recalculate an alternate route when the original route is unavailable.
NearestVertexFind the closest vertex and coordinate of a geometry to a point.
OfflineRoutingSolve a route on-the-fly using offline data.
PerformValveIsolationTraceRun a filtered trace to locate operable features that will isolate an area from the flow of network resources.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.
ShowPopupShow predefined popups from a web map.
SketchOnMapUse the Sketch Editor to edit or sketch a new point, line, or polygon geometry on to a map.
SpatialOperationsFind the union, intersection, or difference of two geometries.
SpatialRelationshipsDetermine spatial relationships between two geometries.
SurfacePlacementsPosition graphics relative to a surface using different surface placement modes.
TraceUtilityNetworkDiscover connected features in a utility network using connected, subnetwork, upstream, and downstream traces.
UpdateGeometriesUpdate a feature's location in an online feature service.
ViewshedGeoElementAnalyze the viewshed for an object (GeoElement) in a scene.