How to refresh layers on map after updating

239
3
09-14-2018 08:40 AM
Highlighted
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

Reply
0 Kudos
3 Replies
Highlighted
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

Reply
0 Kudos
Highlighted
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();
                    }
                }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Reply
0 Kudos
Highlighted
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

Reply
0 Kudos