Hi all,
I'm editing programmatically both the attributes and the geometry of features from a feature layer pointing to a feature service. When the target feature is in the current map extent or you have previously navigated to its location (I'm guessing this means that the feature is in memory) then everything behaves as expected, the feature is rendered with the new geometry and the attribute appears with the new value in the pop-up window. However, when the target feature if far away from any location you have previously navigated to, then two issues occur:
This happens when the edits haven't been persisted yet (before you press the button Save Edits).
I'm using ArcGIS Pro 2.8.3 and ArcGIS Pro SDK for .NET 2.8.0.29751. A copy of the code can be found below:
await QueuedTask.Run(async () =>
{
long oid = 236;
var spatialReference = SpatialReferenceBuilder.CreateSpatialReference(2157);
Map map = MapView.Active.Map;
FeatureLayer featureLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(l => l.Name == "Feature Service");
var editOperation = new EditOperation();
editOperation.Name = "Update test";
var attributes = new Dictionary<string, object>();
attributes["Name"] = "New Name";
MapPoint minPt = MapPointBuilder.CreateMapPoint(609213, 746811);
MapPoint maxPt = MapPointBuilder.CreateMapPoint(609235, 746827);
Envelope envelope = EnvelopeBuilder.CreateEnvelope(minPt, maxPt);
Polygon polygon = PolygonBuilder.CreatePolygon(envelope, spatialReference);
editOperation.Modify(featureLayer, oid, polygon, attributes);
await editOperation.ExecuteAsync();
});