I take some features from an InMemoryFeatureLayer and throw them into the Map’s EditOverlay like so:
foreach (InMemoryFeatureLayer layer in (MyMap.Overlays[DrawingOverlay] as LayerOverlay).Layers)
{
foreach (Feature feature in layer.InternalFeatures)
{
MyMap.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature.Id, feature);
}
}
MyMap.EditOverlay.CalculateAllControlPoints();
MyMap.Refresh(DrawingOverlay);
After editing the shapes (via dragging a vertex, rotating the shape, moving it, etc.) I do the following to end the edit mode:
private void EditFeatures_Ended()
{
//Clear any features in the DrawingOverlay
foreach (InMemoryFeatureLayer layer in (MyMap.Overlays[DrawingOverlay] as LayerOverlay).Layers)
{
layer.InternalFeatures.Clear();
}
//Add each feature in the EditOverlay to the appropriate layer in DrawingOverlay based on its shape
foreach (Feature feature in MyMap.EditOverlay.EditShapesLayer.InternalFeatures)
{
BaseShape shape = feature.GetShape();
if (typeof(LineShape) == shape.GetType())
{
(MyMap.FindFeatureLayer(LinesLayer) as InMemoryFeatureLayer).InternalFeatures.Add(feature);
}
else if (typeof(PolygonShape) == shape.GetType())
{
(MyMap.FindFeatureLayer(PolygonsLayer) as InMemoryFeatureLayer).InternalFeatures.Add(feature);
}
else if (typeof(PointShape) == shape.GetType())
{
(MyMap.FindFeatureLayer(PointsLayer) as InMemoryFeatureLayer).InternalFeatures.Add(feature);
}
}
OnyxMap.EditOverlay.EditShapesLayer.Open();
OnyxMap.EditOverlay.EditShapesLayer.Clear(); //remove all the features in the edit overlay
OnyxMap.EditOverlay.EditShapesLayer.Close();
OnyxMap.Refresh();
}
After this happens, the features disappear off the map until I add another shape to the layer. I’m not sure why this is happening. I can verify the features are in the InMemoryFeatureLayers even though they aren’t showing up on the map.