I have a TreeView on my form that lists InMemoryFeatureLayer names for the user to choose from. When they pick one and then click the edit button, I am trying to move everything on that selectedLayer to the EditOverlay and clear out the selectedLayer.
I seem to be moving the features to the EditOverlay just fine, but the original stays on the screen.
Similarly, when I exit edit mode, I copy the features back to the selectedLayer and clear out the EditOverlay. In this case, the shape does disappear from the screen, but that original shape is still sitting there in the old position like some sort of toad. If I enter edit mode again without changing layers, the shape re-appears (on the EditOverlay) in the correct position (where it was when I exited edit mode last) so I must be saving the features to a good place.
What am I doing wrong here?
Dave
Note: in my code, there is only one layer per overlay and the layer name, layer key and overlay key are all the same string value
//entering edit mode
//move everything in the layer selected in Legend to the EditOverlay
InMemoryFeatureLayer selectedLayer = GetSelectedLayer();
foreach (Feature feature in selectedLayer.InternalFeatures)
{
Map.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
}
Map.EditOverlay.CalculateAllControlPoints();
selectedLayer.InternalFeatures.Clear();
Map.Refresh(Map.Overlays[selectedLayer.Name]);
Map.Refresh();
and
// exiting edit mode
InMemoryFeatureLayer selectedLayer = GetSelectedLayer();
foreach (Feature feature in Map.EditOverlay.EditShapesLayer.InternalFeatures)
{
selectedLayer.InternalFeatures.Add(feature);
}
//Clear the Edit Layer
Map.EditOverlay.EditShapesLayer.InternalFeatures.Clear();
//Refresh just these two layers
Map.Refresh(Map.Overlays[selectedLayer.Name]);
Map.Refresh(new Overlay[] { Map.EditOverlay });