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: 100.11.0
Syntax
public abstract Geometry Geometry { get; set; }

Property Value

Type: Geometry
Examples

UWP

Example Name: DeleteFeatures

Delete features from an online feature service.

Code example screen shot.

C#
// 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: 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.UI.Controls;
using System;
using System.Linq;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace ArcGISRuntime.UWP.Samples.DeleteFeatures
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Delete features (feature service)",
        category: "Data",
        description: "Delete features from an online feature service.",
        instructions: "To delete a feature, tap it, then click 'Delete incident'.",
        tags: new[] { "Service", "deletion", "feature", "online", "table" })]
    public partial class DeleteFeatures
    {
        // Path to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

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

        public DeleteFeatures()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            MyMapView.Map = new Map(BasemapStyle.ArcGISStreets);

            // 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.
            MyMapView.Map.OperationalLayers.Add(_damageLayer);

            // 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.
            _damageLayer.ClearSelection();

            // Dismiss any existing callouts.
            MyMapView.DismissCallout();

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

                // Do nothing if there are no results.
                if (!identifyResult.GeoElements.Any())
                {
                    return;
                }

                // 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();
                qp.ObjectIds.Add(featureId);
                FeatureQueryResult queryResult = await _damageLayer.FeatureTable.QueryFeaturesAsync(qp);
                Feature tappedFeature = queryResult.First();

                // Select the feature.
                _damageLayer.SelectFeature(tappedFeature);

                // Show the callout.
                ShowDeletionCallout(tappedFeature);
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString()).ShowAsync();
            }
        }

        private void ShowDeletionCallout(Feature tappedFeature)
        {
            // Create a button for deleting the feature.
            Button deleteButton = new Button();
            deleteButton.Content = "Delete incident";
            deleteButton.Padding = new Thickness(5);
            deleteButton.Tag = tappedFeature;

            // Handle button clicks.
            deleteButton.Click += DeleteButton_Click;

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

        private async void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            // Dismiss the callout.
            MyMapView.DismissCallout();

            try
            {
                // Get the feature to delete from the layer.
                Button deleteButton = (Button) sender;
                Feature featureToDelete = (Feature) deleteButton.Tag;

                // 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.
                await new MessageDialog($"Deleted feature with ID {featureToDelete.Attributes["objectid"]}", "Success!").ShowAsync();
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.ToString(), "Couldn't delete feature.").ShowAsync();
            }
        }
    }
}
XAML
<UserControl 
    x:Class="ArcGISRuntime.UWP.Samples.DeleteFeatures.DeleteFeatures"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock Text="Tap a feature to select it for deletion."
                       TextAlignment="Center" FontWeight="SemiBold" />
        </Border>
    </Grid>
</UserControl>
Examples

Xamarin Forms UWP

Example Name: AddFeatures

Add features to a feature layer.

Code example screen shot.

C#
// 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: 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.Data;
using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using Xamarin.Forms;

namespace ArcGISRuntimeXamarin.Samples.AddFeatures
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Add features",
        category: "Data",
        description: "Add features to a feature layer.",
        instructions: "Tap on a location on the map to add a feature at that location.",
        tags: new[] { "edit", "feature", "online service" })]
    public partial class AddFeatures : ContentPage
    {
        // URL to the feature service.
        private const string FeatureServiceUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0";

        // Hold a reference to the feature table.
        private ServiceFeatureTable _damageFeatureTable;

        public AddFeatures()
        {
            InitializeComponent();
            Initialize();
        }

        private void Initialize()
        {
            // Create the map with streets basemap.
            MyMapView.Map = new Map(BasemapStyle.ArcGISStreets);

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

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

            // Add the layer to the map.
            MyMapView.Map.OperationalLayers.Add(damageLayer);

            // Listen for user taps on the map - this will select the feature.
            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, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
        {
            try
            {
                // Create the feature.
                ArcGISFeature feature = (ArcGISFeature) _damageFeatureTable.CreateFeature();

                // Get the normalized geometry for the tapped location and use it as the feature's geometry.
                MapPoint tappedPoint = (MapPoint) GeometryEngine.NormalizeCentralMeridian(e.Location);
                feature.Geometry = tappedPoint;

                // Set feature attributes.
                feature.SetAttributeValue("typdamage", "Minor");
                feature.SetAttributeValue("primcause", "Earthquake");

                // Add the feature to the table.
                await _damageFeatureTable.AddFeatureAsync(feature);

                // Apply the edits to the service.
                await _damageFeatureTable.ApplyEditsAsync();

                // Update the feature to get the updated objectid - a temporary ID is used before the feature is added.
                feature.Refresh();

                // Confirm feature addition.
                await Application.Current.MainPage.DisplayAlert("Success!", $"Created feature {feature.Attributes["objectid"]}", "OK");
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Error adding feature", ex.ToString(), "OK");
            }
        }
    }
}
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="ArcGISRuntimeXamarin.Samples.AddFeatures.AddFeatures">
  <Grid>
    <esriUI:MapView x:Name="MyMapView"/>
  </Grid>
</ContentPage>
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.
EditBranchVersioningCreate, query and edit a specific server version using service geodatabase.
EditFeatureLinkedAnnotationEdit feature attributes which are linked to annotation through an expression.
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.