How to refresh layers on map after updating

970
4
09-14-2018 08:40 AM
DrewD
by
New Contributor III

I'm working with a basic polygon and point feature class in the same FGDB in the most recent ArcPro 2.2.

Each polygon contains points in a grid, but for some reason when I delete points and recreate them I can't see the changes. The changes ARE being applied to the featureclass, but it will not visually update. I can even select the points where they've been created (but invisible).

Refreshing the map with F5 doesn't help, nor does clearing the cache in the point layer. I'm also using MapView.Active.Redraw(true); but again no luck. surely there's a way of force updating the layer?

Layer not being refreshed

0 Kudos
4 Replies
RichRuh
Esri Regular Contributor

Drew,

Could you share some of the code showing how you are editing the features?  Are you using the EditOperation class, an edit operation callback, or using the low-level geodatabase editing routines?

What kind of data source are you editing?  (File gdb, shape file, sde, etc.)

Thanks,

--Rich

0 Kudos
DrewD
by
New Contributor III

This is a point feature class in a FGDB. I'm adding them through the chained edit operation below:

                long newFeatureID = -1;//temporarily holds ObjID of a new point
                var createOperation = new EditOperation { Name = "REGEN POINTS" };
                var atts = new Dictionary<string, object>();

                //create the points now
                for (int x = (int)minX; x < maxX; x += sampleDist) {
                    for (int y = (int)minY; y < maxY; y += sampleDist) {
                        //first check if point is even within polygon
                        MapPoint pt = MapPointBuilder.CreateMapPoint(x, y);
                        if (EdgeBuffer != 0 ? !GeometryEngine.Instance.Contains(blockpolygon, GeometryEngine.Instance.Buffer(pt, EdgeBuffer)) :
                                            !GeometryEngine.Instance.Contains(blockpolygon, pt))
                            continue;
                        // point IS in polygon, keep going
                        atts.Clear();
                        createOperation = createOperation.CreateChainedOperation();
                        atts.Add("Shape", pt);
                        atts.Add("P_ID", counter_pid);
                        newFeatureID = -1;
                        createOperation.Create(SelectedPointFeatureLayer, atts, (object_id) => newFeatureID = object_id);
                        createOperation.Execute();
                    }
                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RichRuh
Esri Regular Contributor

Drew,

I don't entirely understand the code fragment above, but based on my limited understanding I have two suggestions that might help.

1. CreateChainedOperation() is used when you need to use information from one operation to feel another, and you want to create a single item on the Pro operation stack.  I don't see this happening here.  It looks safe to delete that line of code.

2. I would move the call to createOperation.Execute() out of both loops.  You're left with 

   a. Create an edit operation using new EditOperation()

   b. step through your loop, creating points that are within the block polygon using EditOperation.Create()

   c. Call to EditOperation.Execute(), which should create all of your points at once

Let me know if this works for you,

--Rich

0 Kudos
anonymous_geographer
New Contributor III

I am super late to this conversation, but was struggling with the same issue at Pro 3.2.2. Adding this comment here for any future viewers who may need help with this also.

The MapView.Active.Redraw(true) fails to update my feature layer's renderer within the map. After some digging around, I found this. I tried the mentioned workaround where I simply re-set the feature layer's data connection back to itself, and my feature layers are now properly redrawing as I would expect.

 

featureLayer.SetDataConnection((CIMStandardDataConnection)featureLayer.GetDataConnection());

 

 
.Redraw() appears to be updating the attribute table correctly, just not the renderer. I'm not sure why that is the case, but using .SetDataConnection() method in tandem with .GetDataConnection() is performing both successfully.

0 Kudos