Runny,
Here is a solution for your requirement, it is a sample that shows how to remove a feature on the map. When you run the sample, please notice that after you drawn several map shapes on the map, please save them first, then select any map shapes on the map and execute the remove operation to remove any map shapes what you want. Here is the sample code below:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
Map1.MapUnit = GeographyUnit.DecimalDegree;
WorldMapKitWmsWebOverlay worldMapKitWmsWebOverlay = new WorldMapKitWmsWebOverlay("WorldMapKitOverlay");
Map1.CustomOverlays.Add(worldMapKitWmsWebOverlay);
InMemoryFeatureLayer shapeLayer = new InMemoryFeatureLayer();
shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.FromArgb(180, 102, 255, 102), 10, GeoColor.StandardColors.DarkGreen, 1);
shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Green, 4, true);
shapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(180, 102, 255, 102), GeoColor.StandardColors.DarkGreen, 1);
shapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
shapeLayer.DrawingQuality = DrawingQuality.HighQuality;
LayerOverlay dynamicOverlay = new LayerOverlay("DynamicOverlay");
dynamicOverlay.IsBaseOverlay = false;
dynamicOverlay.TileType = TileType.SingleTile;
dynamicOverlay.Layers.Add("shapeLayer", shapeLayer);
Map1.CustomOverlays.Add(dynamicOverlay);
}
}
protected void buttonSubmit_Click(object sender, ImageClickEventArgs e)
{
LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["DynamicOverlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"];
foreach (Feature feature in Map1.EditOverlay.Features)
{
if (!shapeLayer.InternalFeatures.Contains(feature.Id))
{
shapeLayer.InternalFeatures.Add(feature.Id, feature);
}
}
Map1.EditOverlay.Features.Clear();
Map1.EditOverlay.TrackMode = TrackMode.None;
dynamicOverlay.Redraw();
}
protected void buttonEditShape_Click(object sender, ImageClickEventArgs e)
{
LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["DynamicOverlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"];
foreach (Feature feature in shapeLayer.InternalFeatures)
{
Map1.EditOverlay.Features.Add(feature.Id, feature);
}
shapeLayer.InternalFeatures.Clear();
Map1.EditOverlay.TrackMode = TrackMode.Edit;
dynamicOverlay.Redraw();
}
protected void buttonDeleteShape_Click(object sender, ImageClickEventArgs e)
{
LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["DynamicOverlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"];
shapeLayer.InternalFeatures.Remove(Session["FeatureID"].ToString());
//shapeLayer.InternalFeatures.Clear();
Map1.EditOverlay.TrackMode = TrackMode.None;
dynamicOverlay.Redraw();
}
protected void Map1_Click(object sender, MapClickedEventArgs e)
{
LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["DynamicOverlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"];
shapeLayer.Open();
Collection<Feature> selectedFeatures = shapeLayer.QueryTools.GetFeaturesContaining(e.Position, ReturningColumnsType.NoColumns);
shapeLayer.Close();
Session["FeatureID"] = selectedFeatures[0].Id;
}
If you have any more questions please let me know,
Thanks,
Scott,