Hello Morten ,
Thanks for your answer , i hope that i'll find a solution to my answer :
My first method i used was to call .CreateFeature((IEnumerable<KeyValuePair<String, Object>>, Geometry))
here's the code :
private async void startLocalDB()
{
var gdb = await Esri.ArcGISRuntime.Data.Geodatabase.OpenAsync(@"C:\Users\mkeddar\Documents\ArcGIS\geodblocal\poly\data\pocdb.geodatabase");
var table = gdb.GeodatabaseFeatureTables.ElementAt(0);
await table.LoadAsync();
MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
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);
var poly = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
var attributes = new Dictionary<string, object>();
attributes.Add("polygon", poly);
if (table.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded)
{
// var lyr = new FeatureLayer(table);
MyMapView.Map = new Map();
// MyMapView.Map.OperationalLayers.Add(lyr);
var feature = table.CreateFeature(attributes,locationPoint);
await table.AddFeatureAsync(feature);
}
}
the error point on table.CreateFeature(attributes,locationPoint); : the specified method is not supported
the second try was with templates so i did :
var template = table.FeatureTemplates.FirstOrDefault() ?? table.FeatureTypes.FirstOrDefault(t => t.Templates.Any())?.Templates?.FirstOrDefault();
var feature = table.CreateFeature(template);
await table.AddFeatureAsync(feature);
and i have an error saying that error.: "An internal geodatabase error.: Create is not supported on the table".
I even tried with (.mpk) file to edit the feature Class (feature Table) but it doesn't work cause when i capture the Url of the local service it says that the only supported operations are (Query) there's no edit , update,create,or delete .i think that the runtime is not a very complete API
here's my code with (.mpk ) file
private async void AddNewFeature2D()
{
var service = new LocalFeatureService(@"C:\Users\mkeddar\Documents\ArcGIS\poly.mpk");
await service.StartAsync();
var uri = new Uri($"{service.Url}/0");
var featureTable = new ServiceFeatureTable(uri);
MapPoint locationPoint = new MapPoint(-2.708471, 56.096575, 5000, SpatialReferences.Wgs84);
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 poly = new Esri.ArcGISRuntime.Geometry.Polygon(pointCollection);
var attributes = new Dictionary<string, object>();
attributes.Add("polygon", poly);
await featureTable.LoadAsync();
//if the table os loaded successfully , create a new feature layer for the table and add it to the map
//Editer la feature Layer
var template = featureTable.FeatureTemplates.FirstOrDefault() ??featureTable.FeatureTypes.FirstOrDefault(t => t.Templates.Any())?.Templates?.FirstOrDefault();
var feature = featureTable.CreateFeature(template);
//var feature = featureTable.CreateFeature(attributes,locationPoint) //Doesn't work error: method is not supported
//add the new feature this updates local copy of the table
await featureTable.AddFeatureAsync(feature);
//push this update (applyEdit)
// push this update (apply edits) 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);
}
}
//IReadOnlyList<EditResult> editResults = await table2D.a
}
i 've shared my mpk and .geodatabse file notice no lethod worked