AnsweredAssumed Answered

add a feature to my feature class

Question asked by ManelKeddar on Jul 20, 2017
Latest reply on Jul 27, 2017 by ManelKeddar

Hello every one ,

I'm trying to add a 2D feature (polygon) to my feature layer using ServiceFeatureTable  so i tried to  let the user to click the map   to specify a new feature's location by listening to a click event on your map view, which in turn will call a function for adding a new feature. but my method doesn't seems good enough to work here's my code 


  public MainWindow()
MyMapView.Map = new Map(Basemap.CreateTopographic());
MyMapView.GeoViewTapped += MymapView_GeoViewTapped;


private async void MymapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
//get the click point in geographic coordinates
var mapClickPoint = e.Location;
var pointCollection = new Esri.ArcGISRuntime.Geometry.PointCollection(SpatialReferences.Wgs84);
pointCollection.Add(-109.048, 40.998);
pointCollection.Add(-102.047, 40.998);
pointCollection.Add(-102.037, 36.989);
pointCollection.Add(-109.048, 36.998);

//create a new polygon from the point collection

var polygon = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);

var mapService = new LocalFeatureService(@"C:\Users\lolo\Documents\ArcGIS\3Dservitude.mpk");
await mapService.StartAsync();
var featureTable2DUri = new System.Uri($"{mapService.Url}/1");
var featureTable = new ServiceFeatureTable(featureTable2DUri);
await featureTable.LoadAsync();
//call the function that will add the new feature at this location
AddNewFeature(featureTable, mapClickPoint, 2018, polygon, 7000, 70000);


private async void AddNewFeature( ServiceFeatureTable featureTable,MapPoint location ,int servitude , Esri.ArcGISRuntime.Geometry.Polygon poly,int area , int lenght)

var attributes = new Dictionary<string, object>();
attributes.Add("servitude", servitude);
attributes.Add("polygone", poly);
attributes.Add("area", area);
attributes.Add("lenght", lenght);

//create a new feature in the GEOM2DServitudeGabarit table , pass in the attributes and geometry

var template = featureTable.FeatureTemplates.FirstOrDefault() ?? featureTable.FeatureTypes.FirstOrDefault(t => t.Templates.Any())?.Templates?.FirstOrDefault();
var newFeature = featureTable.CreateFeature(attributes, location);
await featureTable.AddFeatureAsync(newFeature);
var layer = new FeatureLayer(featureTable);

//push this update (apply edit) to the feature service
IReadOnlyList<EditResult> editResults = await featureTable.ApplyEditsAsync();
// check the results for errors
foreach (var r in editResults)
if (r.CompletedWithErrors)
Console.WriteLine("Edit to Object '" + r.ObjectId + "' failed: " + r.Error.Message);



i have a problem with (var newFeature = featureTable.CreateFeature(attributes, location);) looks doesn't support it although i have the right type parameters .and my code doesn't do any thing i join my mpk file .Any one can help please

thanks in advanced