Select to view content in your preferred language

Inconsistent behavior and rendering when editing programmatically a not-in-memory feature from a feature service

12-06-2021 08:48 AM
New Contributor III

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:

  • The attribute is updated but not the geometry. The attribute appears with the new value on the pop-up window but the map is still rendering the old geometry.
  • Inconsistent/intermittent rendering of the new geometry. If you navigate to the location where the new geometry should be you can see that it is rendered occasionally for some zoom levels, while not for others. However, if you try to identify or select the feature even when it is rendered, then nothing is found on that location. I have attached a gif showing this behavior.

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 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();


0 Kudos
0 Replies